1 Reply Latest reply on Jan 4, 2013 7:41 PM by twasyl

    Unable to generate runnable jar

      I have a Eclipse project with the latest JDK and JavaFX setup. The project runs fine in Eclipse, when I run through the "RUN" button, but when I try to export it as a runnable jar it gives me a NullPointerException, below is the stack trace.

      Exception in Application start method
      Exception in thread "main" java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
      Caused by: java.lang.RuntimeException: Exception in Application start method
      at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403)
      at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
      at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
      at java.lang.Thread.run(Thread.java:722)
      Caused by: java.lang.NullPointerException
      at controllers.Main.start(Main.java:183)
      at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
      at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206)
      at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
      at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
      ... 1 more

      I've tried using the javafxpackager tool to create a jar as well, with the following command line:
      javafxpackager -createjar -appclass controllers.Main -srcdir bin -classpath lib/*.jar -outdir dist -outfile M1000_software -v

      but then I receive an error
      This application requires a newer version of the Java runtime. Please download and install the latest Java runtime from java.com. Then restart the application.

      Any help would be appreciated.
        • 1. Re: Unable to generate runnable jar

          Do you have a main method that launchs you Application class?
          You can also try this ant script (very simple one) I used for generating a runnable JAR with IntelliJ IDEA: http://thierrywasyl.wordpress.com/2012/12/07/build-javafx-runnable-jar-with-intellij-idea-and-ant/

          Hope it helps