B4J Question [SOLVED] Exception in thread "JavaFX Application Thread"

jroriz

Active Member
Licensed User
Longtime User
I have a small project to show images.
It's very simple and integrates a floating window for some specific functions.
The program worked without problems until I had to format the PC and reinstall everything.
I have no problems running the program directly from the IDE, but if I run the JAR file directly, the following error occurs:


C:\desenv\Mostra form\Objects>java -jar mostraform.jar
Exception in thread "JavaFX Application Thread" Exception in thread "main" 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$2(LauncherImpl.java:352)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(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$4(WinApplication.java:185)
at java.lang.Thread.run(Unknown Source)
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


Could anyone help?

Complete project attached (it's very simple).
The program needs the c:/desenv/telas folder with some .png files in it.
 

Attachments

  • Mostra form.zip
    3.9 KB · Views: 222

DonManfred

Expert
Licensed User
Longtime User
Use a higher JAVA Version. java 11 probably. One library is compiled with a higher java-version than you are using.
 
Upvote 1

jroriz

Active Member
Licensed User
Longtime User
I'm using java 11.0.1 and the libraries I'm using in the project are these:


1638977129212.png


Removed additional libraries (jawrobot and jreflection) but no success...
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
From the look of it you have Java 8 installed and that is what is trying to run the jar when you type that command line. Java 11 by default does not execute from the command line when installed.
See
and
 
Upvote 0

jroriz

Active Member
Licensed User
Longtime User
From the look of it you have Java 8 installed and that is what is trying to run the jar when you type that command line. Java 11 by default does not execute from the command line when installed.
See
and

Thanks.
Solved using the following DOS command:
B4X:
javaw --module-path C:\Java\javafx\lib --add-modules ALL-MODULE-PATH -jar %1
where %1 is the JAR file to be executed.
 
Upvote 0

jroriz

Active Member
Licensed User
Longtime User
From the look of it you have Java 8 installed and that is what is trying to run the jar when you type that command line. Java 11 by default does not execute from the command line when installed.
See
and

Thank you.
Solved using the DOS command as follow:

B4X:
c:\java\bin\javaw --module-path C:\Java\javafx\lib --add-modules ALL-MODULE-PATH -jar %1

where %1 is your JAR file.
 
Upvote 0
Top