B4J Question OpenJDK11 compilations throw error

Num3

Active Member
Licensed User
Longtime User
Good day all,

I have been experimenting with the OpenJDK11.0.1 from B4X site and everything works well when running from the IDE, but after i compile the project and try running it by double clicking (windows 10), the Java Platform SE gets loaded and stuck in memory. The same code compiled with JDK8-u202 runs with no problems.

If i use the console to run java.exe (java.exe -jar test.jar) both the OpenJDK and the standard java.exe throw this error:

Exception in thread "JavaFX Application Thread" Exception in thread "main" 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 sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.NullPointerException
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:383)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
... 5 more
java.lang.UnsupportedClassVersionError: b4j/example/main has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
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 com.sun.javafx.application.LauncherImpl.lambda$launchApplicationWithArgs$155(LauncherImpl.java:352)
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)
at java.lang.Thread.run(Unknown Source)
 
Last edited:

Daestrum

Expert
Licensed User
Longtime User
Java 11 doesn't have a runtime environment (JRE) like previous versions.

You are trying to run the jar using the Java 8 JRE (the one your system knows about) but it knows the jar is java 11 (version 53) so cannot run it.

Long answer - yes you can alter your system setup to get it to work as previous version did, but it involves editing the registry and is a real PITA and java 8 won't run as normal afterwards.

Short answer - use the Packager11 and install it as an executable.
 
Upvote 0

Num3

Active Member
Licensed User
Longtime User
Short answer - use the Packager11 and install it as an executable.

Still no luck...
Installed B4JPackager11, edited the code to match the test.jar file compiled with OpenJDK...
Run the debug.bat and got this:
B4X:
D:\Programming\B4JPackager11\Objects\temp\build>cd bin

D:\Programming\B4JPackager11\Objects\temp\build\bin>java.exe @release_java_modules.txt -m b4j/b4j.example.main
main._process_globals (java line: -1)
java.lang.NoClassDefFoundError: javafx/scene/web/WebView
        at b4j/b4j.example.main._process_globals(Unknown Source)
        at b4j/b4j.example.main.initializeProcessGlobals(Unknown Source)
        at b4j/b4j.example.main.start(Unknown Source)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(Unknown Source)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(Unknown Source)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source)
        at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javafx.scene.web.WebView
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        ... 12 more


D:\Programming\B4JPackager11\Objects\temp\build\bin>pause
 
Upvote 0
Top