0

I've got a project that runs fine in IntelliJ IDEA 2017 (a simple board game), which is a JavaFX Project. I've set this up to export as a jar using File > Project Structure > Artifacts > + > JAR > From Module With Dependencies which generated a jar file.

However when I run this jar using java -jar program.jar, I get the following exception:

Exception in Application start method
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
        at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: sun/plugin/dom/exception/InvalidStateException
        at main.GameManager.<init>(GameManager.java:23)
        at main.Main.start(Main.java:48)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
        at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
        at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
        ... 1 more
Caused by: java.lang.ClassNotFoundException: sun.plugin.dom.exception.InvalidStateException
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 11 more
Exception running application main.Main

The important part of that is the NoClassDefFoundError from main.GameManager, line 23. This line is creating a new instance of an object, the class for which is in a separate package.

Any ideas on how to fix this issue?

Thanks!

Matthew Winfield
  • 827
  • 4
  • 10
  • 25
  • possible duplicate for [Jar missing Sun classes](https://stackoverflow.com/questions/24169576/jar-missing-sun-classes) – Ivonet Dec 10 '17 at 22:27
  • Btw for creating JavaFX applications, there is dedicated (in Ultimate Edition) 'JavaFX Application' artifact type. If you are packaging it as a jar archive, make sure that the not found class is actually present in the archive. Check also https://stackoverflow.com/a/30162808/2000323 – Andrey Dec 12 '17 at 15:19
  • I've checked inside the jar and the class is there, along with any resources it may need. I've also tried using the dedicated JavaFX Application exprt, which has the same issue. – Matthew Winfield Dec 12 '17 at 19:02

0 Answers0