1

Hi i have problem with ant run [java] Exception in thread "main" java.lang.reflect.InvocationTargetException but when i run it outside of ant it works well, i tried various modifications with classpaths etc.. but nothing helped me, can you help me please? I write my project in JavaFX and it is GUI application. My build.xml file is:

<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>

Whole exception trace is:

[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
Raiper34
  • 537
  • 2
  • 6
  • 20
  • Linux or Windows? I guess linux from the build.xml. https://stackoverflow.com/questions/5253072/java-unable-to-create-new-native-thread – pleft Sep 29 '17 at 13:30

1 Answers1

0

This is a run time exception as indicated by stack trace.

Caused by: java.lang.OutOfMemoryError: unable to create new native thread

Check 1. If your RAM is not getting filled up 2. Increase size of your JVM

These should help.