I using this guide added my dependencies to main jar JavaFX jar with dependencies bundled i am facing dependencies issue which causing Class not found exception. My Pom is exactly like mentioned in above link. i use dependencies plugin to copy dependencies to lib folder in target.
Here is my stack trace
Try calling Class.forName(com.client.main.App) using classLoader = j
ava.net.URLClassLoader@3c9076d
found class: class com.client.main.App
launchApp: Try calling com.sun.javafx.application.LauncherImpl.launchApplication
Autoconfig of proxy is completed.
JavaFX: using com.sun.javafx.tk.quantum.QuantumToolkit
Exception in Application init 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.javafx.main.Main.launchApp(Main.java:698)
at com.javafx.main.Main.main(Main.java:871)
Caused by: java.lang.RuntimeException: Exception in Application init method
at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown So
urce)
at com.sun.javafx.application.LauncherImpl.access$000(Unknown Source)
at com.sun.javafx.application.LauncherImpl$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: com/google/inject/Module
at com.nuaxis.rpas.client.main.App.init(App.java:25)
... 4 more
Caused by: java.lang.ClassNotFoundException: com.google.inject.Module
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 java.lang.ClassLoader.loadClass(Unknown Source)
... 5 more
Done with invoke and wait
Maven Ant Task in maven pom file using maven ant plugin
<jfxjar destfile="${project.build.directory}/${project.build.finalName}">
<fileset dir="${project.build.directory}/classes" />
<fileset dir="${project.build.directory}/lib/" includes="*.jar" />
<application name="${project.name}" mainClass="com.client.main.App" />
<resources>
<fileset dir="${project.build.directory}/lib/" includes="*.jar" />
</resources>
</jfxjar>
Here is my Fx Application Class code
public class App extends Application {
/*public static Logger mLogger = LoggerFactory.getLogger(App.class); */
public static Injector injector;
public static AppHandler mAppHandler;
@Override
public void init() throws Exception {
// TODO Auto-generated method stub
super.init();
injector = Guice.createInjector(new GuiceModule());/*This line cause exception*/
mAppHandler = injector.getInstance(AppHandler.class);
if(mAppHandler!=null)
mAppHandler.startHandler();
}
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("/fxml/FXMLDocument.fxml"));
Scene scene = new Scene(root);
scene.getStylesheets().add("/styles/style.css");
stage.setTitle("RPAS Java Client");
stage.getIcons().add(new Image("/images/RPAS Java Client.png"));
stage.setScene(scene);
stage.show();
}
@Override
public void stop() throws Exception {
mAppHandler.stopHandler();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
Here is my understanding
Now what i understand is my dependencies are not properly loading. ant "jar making" task makes jar without any issues. when i double click it through exception. I opened the jar and here is my Manifest
Manifest-Version: 1.0
JavaFX-Version: 2.2
JavaFX-Application-Class: com.client.main.App
JavaFX-Class-Path: guice-3.0.jar hamcrest-core-1.3.jar javax.inject-1.jar log4j-1.2.15.jar slf4j-api-1.7.7.jar slf4j-log4j12-1.7.7.jar
Created-By: JavaFX Packager
Main-Class: com/javafx/main/Main
I also wonder when i saw that jar making process add com.javafx.main.Main.java file to the code automatically which first check Run time(JRE and FX) and then if all successful invoke the com.sun.javafx.Application.LauncherImp .
can any body help me?