Ant运行InvocationTargetException

时间:2017-09-29 13:24:16

标签: java javafx ant invocationtargetexception

嗨我有蚂蚁运行的问题 [java]线程中的异常" main" java.lang.reflect.InvocationTargetException 但是当我在ant之外运行它运行良好时,我尝试使用类路径等进行各种修改..但没有任何帮助我,你能帮我吗?我在JavaFX中编写项目,它是GUI应用程序。我的build.xml文件是:

<property name="java.home" value="/usr/local/share/Java"/>
<property name="source.dir" value="src"/>
<property name="out.dir" value="build"/>
<property name="out.dir.classes" value="${out.dir}/classes" />
<property name="out.dir.dist" value="${out.dir}/dist"/>
<property name="app.jar.name" value="TesterFX.jar"/>

<path id="classpath">
    <fileset dir="${java.home}/lib" includes="**/*.jar"/>
</path>

<target name="clean">
    <delete dir="${out.dir}"/>
</target>

<target name="init" depends="clean">
    <mkdir dir="${out.dir}"/>
    <mkdir dir="${out.dir.classes}"/>
    <mkdir dir="${out.dir.dist}"/>
</target>

<target name="compile" depends="init">
    <javac srcdir="${source.dir}" destdir="${out.dir}/classes" classpathref="classpath"
           source="1.7"
           target="1.7" />
    <copy todir="${out.dir}/classes">
        <fileset dir="${source.dir}">
            <include name="**/*.png" />
            <include name="**/*.fxml" />
            <include name="**/*.css" />
        </fileset>
    </copy>
</target>

<target name="build" depends="compile">
    <path id="fxant">
        <filelist>
            <file name="${java.home}\..\lib\ant-javafx.jar"/>
            <file name="${java.home}\lib\ext\jfxrt.jar"/>
        </filelist>
    </path>

    <taskdef resource="com/sun/javafx/tools/ant/antlib.xml"
             uri="javafx:com.sun.javafx.tools.ant"
             classpathref="fxant"/>
    <fx:application id="TesterFX" mainClass="sample.Main"/>
    <fx:jar destfile="${out.dir.dist}/${app.jar.name}">
        <fx:application refid="TesterFX"/>

        <manifest>
            <attribute name="Implementation-Vendor"
                       value="Thierry"/>
            <attribute name="Implementation-Title"
                       value="TesterFX"/>
            <attribute name="Implementation-Version" value="1.0"/>
        </manifest>

        <fileset dir="${out.dir.classes}"/>
    </fx:jar>
</target>

<target name="run" depends="build">
    <java jar="${out.dir.dist}/${app.jar.name}" fork="true"/>
</target>

<target name="default" depends="run">
</target>

整个异常跟踪是:

[java] Exception in thread "main" java.lang.reflect.InvocationTargetException
 [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 [java]     at java.lang.reflect.Method.invoke(Method.java:498)
 [java]     at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
 [java] Caused by: java.lang.RuntimeException: java.lang.OutOfMemoryError: unable to create new native thread
 [java]     at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:267)
 [java]     at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:211)
 [java]     at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:675)
 [java]     at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:337)
 [java]     at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
 [java]     ... 5 more
 [java] Caused by: java.lang.OutOfMemoryError: unable to create new native thread
 [java]     at java.lang.Thread.start0(Native Method)
 [java]     at java.lang.Thread.start(Thread.java:717)
 [java]     at com.sun.glass.ui.gtk.GtkApplication.<init>(GtkApplication.java:76)
 [java]     at com.sun.glass.ui.gtk.GtkPlatformFactory.createApplication(GtkPlatformFactory.java:41)
 [java]     at com.sun.glass.ui.Application.run(Application.java:146)
 [java]     at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:257)
 [java]     ... 9 more
 [java] Java Result: 1

1 个答案:

答案 0 :(得分:0)

这是一个由堆栈跟踪指示的运行时异常。

引起:java.lang.OutOfMemoryError:无法创建新的本地线程

检查 1. 如果您的 RAM 没有被填满 2. 增加 JVM 的大小

这些应该会有所帮助。