1

I'm new in JavaFX. I created JavaFX project with maven and I add all dependecies. Project in idea works perfectly but when I build it in maven and try to open in target folder jar dosn't react and it gives following errors.

java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) 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) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at sample.JdbcPlainTest.createConnection(JdbcPlainTest.java:21) at sample.JdbcPlainTest.ProductsSelectQuery(JdbcPlainTest.java:84) at sample.Controller.initialize(Controller.java:84) at javafx.fxml.FXMLLoader.loadImpl(Unknown Source) at javafx.fxml.FXMLLoader.loadImpl(Unknown Source) at javafx.fxml.FXMLLoader.loadImpl(Unknown Source) at javafx.fxml.FXMLLoader.loadImpl(Unknown Source) at javafx.fxml.FXMLLoader.loadImpl(Unknown Source) at javafx.fxml.FXMLLoader.loadImpl(Unknown Source) at javafx.fxml.FXMLLoader.loadImpl(Unknown Source) at javafx.fxml.FXMLLoader.load(Unknown Source) at sample.Main.start(Main.java:14) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153 (Unknown Source) at com.sun.javafx.application.LauncherImpl$$Lambda$51/881058039.run(Unkn own Source) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(Unknown Source) at com.sun.javafx.application.PlatformImpl$$Lambda$45/584634336.run(Unkn own Source) at com.sun.javafx.application.PlatformImpl.lambda$null$164(Unknown Sourc e) at com.sun.javafx.application.PlatformImpl$$Lambda$47/474818150.run(Unkn own Source) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(Unknown S ource) at com.sun.javafx.application.PlatformImpl$$Lambda$46/501263526.run(Unkn own Source) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$141(Unknown Source) at com.sun.glass.ui.win.WinApplication$$Lambda$37/96639997.run(Unknown S ource) at java.lang.Thread.run(Unknown Source) 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(Unk nown Source) at com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Sou rce) 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(Unknown So urce) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$147( Unknown Source) at com.sun.javafx.application.LauncherImpl$$Lambda$48/815033865.run(Unkn own Source) at java.lang.Thread.run(Unknown Source) Caused by: javafx.fxml.LoadException: file:/D:/work%20proyeqt%20immidetely/JASMIN/Qassa%20-%20CopyWORKING/target/Qassa Copy-1.0-SNAPSHOT.jar!/sample.fxml

    at javafx.fxml.FXMLLoader.constructLoadException(Unknown Source)
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.load(Unknown Source)
    at sample.Main.start(Main.java:14)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153

(Unknown Source) at com.sun.javafx.application.LauncherImpl$$Lambda$51/881058039.run(Unkn own Source) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(Unknown Source) at com.sun.javafx.application.PlatformImpl$$Lambda$45/584634336.run(Unkn own Source) at com.sun.javafx.application.PlatformImpl.lambda$null$164(Unknown Sourc e) at com.sun.javafx.application.PlatformImpl$$Lambda$47/474818150.run(Unkn own Source) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(Unknown S ource) at com.sun.javafx.application.PlatformImpl$$Lambda$46/501263526.run(Unkn own Source) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$141(Unknown Source) at com.sun.glass.ui.win.WinApplication$$Lambda$37/96639997.run(Unknown S ource) ... 1 more Caused by: java.lang.NullPointerException at sample.JdbcPlainTest.ProductsSelectQuery(JdbcPlainTest.java:108) at sample.Controller.initialize(Controller.java:84) ... 23 more Exception running application sample.Main

  • java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver: seems you are missing a dependency for the MySQL JDBC driver – Henry Jun 07 '18 at 12:18

1 Answers1

1

seems your dependencies are not included into your jar. Open your .jar and see whether all the dependency classes (like com.mysql.cj.jdbc.Driver) are inside. If they are not please see, Including dependencies in a jar with Maven.

Dushmantha
  • 2,911
  • 1
  • 14
  • 21