var imageView = new ImageView();
var settings = JmeToJfxIntegrator.prepareSettings(new AppSettings(true), 60);
var application = new MySomeApplication();
JmeToJfxIntegrator.startAndBindMainViewPort(application, imageView, Thread::new);
@Override
public void start(Stage primaryStage) {
try {
BorderPane root = new BorderPane();
ImageView imageView = new ImageView();
AppSettings settings = JmeToJfxIntegrator.prepareSettings(new AppSettings(true), 60);
JmeToJfxApplication application = new JmeToJfxApplication();
JmeToJfxIntegrator.startAndBindMainViewPort(application, imageView, Thread::new);
root.setCenter(imageView);
Scene scene = new Scene(root,1440,720);
primaryStage.setTitle("Test Jme Jfx");
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}
But I’m getting this error now:
Exception in Application start method
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:473)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:372)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:941)
Caused by: java.lang.RuntimeException: Exception in Application start method
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:973)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:198)
at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: java.lang.NoClassDefFoundError: com/jme3/system/AppSettings
at jmejfxtest.JmeJfxTest.start(JmeJfxTest.java:25)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:919)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$11(PlatformImpl.java:449)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$9(PlatformImpl.java:418)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:417)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
… 1 more
Caused by: java.lang.ClassNotFoundException: com.jme3.system.AppSettings
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
… 10 more
Exception running application jmejfxtest.JmeJfxTest
And when trying to build pom.xml, here is what I get (with clean test maven goal):
[INFO] Scanning for projects…
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building jmejfxtest 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] — maven-clean-plugin:2.5:clean (default-clean) @ jmejfxtest —
[INFO] Deleting /users/lucaparl/Documents/PFE 2018 ETIS/jmejfxtest/target
[INFO]
[INFO] — maven-resources-plugin:2.6:resources (default-resources) @ jmejfxtest —
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] — maven-compiler-plugin:3.1:compile (default-compile) @ jmejfxtest —
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /users/lucaparl/Documents/PFE 2018 ETIS/jmejfxtest/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] error reading /users/lucaparl/.m2/repository/org/jmonkeyengine/jme3-core/3.2.0-stable/jme3-core-3.2.0-stable.jar; ZipFile invalid LOC header (bad signature)
[ERROR] Source option 5 is no longer supported. Use 6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.
[INFO] 3 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.308 s
[INFO] Finished at: 2018-07-06T14:50:19+02:00
[INFO] Final Memory: 9M/40M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project jmejfxtest: Compilation failure: Compilation failure:
[ERROR] error reading /users/lucaparl/.m2/repository/org/jmonkeyengine/jme3-core/3.2.0-stable/jme3-core-3.2.0-stable.jar; ZipFile invalid LOC header (bad signature)
[ERROR] Source option 5 is no longer supported. Use 6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.
[ERROR] → [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[INFO] Scanning for projects…
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building jmejfxtest 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] — maven-clean-plugin:2.5:clean (default-clean) @ jmejfxtest —
[INFO] Deleting /users/lucaparl/Documents/PFE 2018 ETIS/jmejfxtest/target
[INFO]
[INFO] — maven-resources-plugin:2.6:resources (default-resources) @ jmejfxtest —
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] — maven-compiler-plugin:3.1:compile (default-compile) @ jmejfxtest —
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /users/lucaparl/Documents/PFE 2018 ETIS/jmejfxtest/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] error reading /users/lucaparl/.m2/repository/org/jmonkeyengine/jme3-core/3.2.0-stable/jme3-core-3.2.0-stable.jar; ZipFile invalid LOC header (bad signature)
[ERROR] Source option 5 is no longer supported. Use 6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.
[INFO] 3 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.276 s
[INFO] Finished at: 2018-07-06T16:22:50+02:00
[INFO] Final Memory: 9M/40M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project jmejfxtest: Compilation failure: Compilation failure:
[ERROR] error reading /users/lucaparl/.m2/repository/org/jmonkeyengine/jme3-core/3.2.0-stable/jme3-core-3.2.0-stable.jar; ZipFile invalid LOC header (bad signature)
[ERROR] Source option 5 is no longer supported. Use 6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.
[ERROR] → [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
and java code:
Erreur : impossible de trouver ou de charger la classe principale jmejfxtest.JmeJfxTest
Causé par : java.lang.ClassNotFoundException: jmejfxtest.JmeJfxTest
I think you have wrong cached jME libraries, could you clear maven local cache?
Also, you need to add source/target compilation properties to compile your project as java 8.
I’ve been trying to do the other way around by embedding JavaFX buttons into JME using the other example provided, but I’m wondering what I should write in my Main class code. I tried this:
java.lang.NullPointerException
at com.jme3.jfx.injme.cursor.proton.ProtonCursorProvider.(ProtonCursorProvider.java:48)
at com.jme3.jfx.injme.JmeFxContainerImpl.install(JmeFxContainerImpl.java:71)
at com.jme3.jfx.injme.JmeFxContainer.install(JmeFxContainer.java:26)
at jmejfxtest.MyApplication.simpleInitApp(MyApplication.java:17)
at jmejfxtest.JmeJfxTest.start(JmeJfxTest.java:50)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:919)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$11(PlatformImpl.java:449)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$9(PlatformImpl.java:418)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:417)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
at java.base/java.lang.Thread.run(Thread.java:844)