B4J Question JavaFX runtime components are missing

amorosik

Expert
Licensed User
B4J ver 9.10
Strumenti / Configura Percorsi = C:\Program Files\Java\jdk-11.0.1\bin\javac.exe
Java11+FxRuntime downloaded from B4x.com web site

B4X:
C:\Windows\System32>java -version 
java version "1.8.0_261"
Java(TM) SE Runtime Environment (build 1.8.0_261-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)

When i try to start a jar with
c:\program\java\jdk-11-0.1\bin\java.exe -jar c:\test\test.jar

this error appear: "Error: JavaFx runtime components are missing, and ae required to run this application"

Also using integrated Packager11 the .exe not start correctly

What is the reason of above error, and how to correct?
 

Daestrum

Expert
Licensed User
Longtime User
Not sure you can use Packager11 for Java 8 ( I may be wrong )

Sorry just noticed it was Windows reporting the version not the IDE.
 
Upvote 0

aminoacid

Active Member
Licensed User
Longtime User
Looks like you have both Java 8 and Java 11 on your computer. Did you compile your program with 8 or 11 ? Make sure that the path to javac.exe points to the correct exe file (i.e. for Java11)

[edit]
Sorry "Strumenti / Configura Percorsi = Configure paths"] Need to brush up on my Italian ?

Did you download Java11+Fx from Erel's link or elsewhere on the forum?
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
C:\Windows\System32>java -version
Try it with
B4X:
c:\program\java\jdk-11-0.1\bin\java.exe -version
to define the java you want to check.
Windows is finding an old version as you do have two javas installed. Maybe javahome set as env var?
 
Upvote 0

amorosik

Expert
Licensed User
Try it with
B4X:
c:\program\java\jdk-11-0.1\bin\java.exe -version
to define the java you want to check.
Windows is finding an old version as you do have two javas installed. Maybe javahome set as env var?

B4X:
C:\>java.exe -version
java version "1.8.0_261"
Java(TM) SE Runtime Environment (build 1.8.0_261-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)

C:\>cd C:\Program Files\Java\jdk-11.0.1\bin

C:\Program Files\Java\jdk-11.0.1\bin>java.exe -version
openjdk version "11.0.1" 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)

C:\Program Files\Java\jdk-11.0.1\bin>

"..Maybe javahome set as env var?.."
No, I don't have any environment variables with the name JAVA_HOME
But shouldn't the version configured on Tools / Configure Paths be used?
 
Upvote 0

amorosik

Expert
Licensed User
Looks like you have both Java 8 and Java 11 on your computer. Did you compile your program with 8 or 11 ? Make sure that the path to javac.exe points to the correct exe file (i.e. for Java11)

[edit]
Sorry "Strumenti / Configura Percorsi = Configure paths"] Need to brush up on my Italian ?

Did you download Java11+Fx from Erel's link or elsewhere on the forum?

"...Java11+FxRuntime downloaded from B4x.com web site..."
 
Upvote 0

amorosik

Expert
Licensed User
If i try to use c:\program\java\jdk-1.8.0-261\bin\javac.exe on "Tools/Configure Path", the .jar produced run fine with
c:\program\java\jdk-1.8.0-261\bin\java.exe -jar c:\test\test.jar
But integrated packager is not available
May be that some library are not compatible with java 11 ?



1630995570989.png
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
But shouldn't the version configured on Tools / Configure Paths be used?
Yes, B4X IS using the configured java!!

YOU are running the command from a windows commandline. WINDOWS is deciding which to use if you do not specify a path!

The integrated packager does need Java 11 as far as i know..

B4JPackager11 is a utility written in B4J that uses the underlying Java tools to create a standalone package that doesn't depend on any other software being installed.
It works with OpenJDK 11 and OpenJDK 14.
 
Last edited:
Upvote 0

aminoacid

Active Member
Licensed User
Longtime User
I now remember .... I had the same problem. You HAVE to include the path to JavaFX and the required modules in the command line. Tried it on my computer:

C:\java\jdk-11.0.1\bin\java.exe --module-path C:\java\jdk-11.0.1\javafx\lib --add-modules=javafx.controls,javafx.fxml,javafx.web -jar PATH-TO-YOUR-JARFILE

Change the paths above for your setup.

In general, the command line is:

%JAVADIR%\bin\java.exe --module-path %JAVADIR%\javafx\lib --add-modules=javafx.controls,javafx.fxml,javafx.web -jar %JARFILE%
 
Upvote 0

amorosik

Expert
Licensed User
Yes, B4X IS using the configured java!!

YOU are running the command from a windows commandline. WINDOWS is deciding which to use if you do not specify a path!

The integrated packager does need Java 11 as far as i know..

No
"..When i try to start a jar with c:\program\java\jdk-11-0.1\bin\java.exe -jar c:\test\test.jar ...."

Then Windows cannot decide wich Java version to start
 
Upvote 0

amorosik

Expert
Licensed User
I now remember .... I had the same problem. You HAVE to include the path to JavaFX and the required modules in the command line. Tried it on my computer:

C:\java\jdk-11.0.1\bin\java.exe --module-path C:\java\jdk-11.0.1\javafx\lib --add-modules=javafx.controls,javafx.fxml,javafx.web -jar PATH-TO-YOUR-JARFILE

Change the paths above for your setup.

In general, the command line is:

%JAVADIR%\bin\java.exe --module-path %JAVADIR%\javafx\lib --add-modules=javafx.controls,javafx.fxml,javafx.web -jar %JARFILE%

Yes, It could be that java.exe takes it from the imposed path while other libraries from other directories
I also tried the system you recommended but I get another error
Any idea?


B4X:
D:\ERP2_MQTT_LISTENER\Objects>"C:\Program Files\Java\jdk-11.0.1\bin\java.exe" --module-path "C:\Program Files\Java\jdk-11.0.1\javafx\lib" --add-modules=javafx.controls,javafx.fxml,javafx.web -jar D:\ERP2_MQTT_LISTENER\Objects\erp2_mqtt_listener.jar D:\ERP2_MQTT_LISTENER\Objects\Erp2_Mqtt_Listener\
2021 09 07 14 23 21 285 - ================================================================================
2021 09 07 14 23 21 309 - Main.AppStart
main._appstart (java line: 361)
java.lang.IllegalAccessError: class impl.org.controlsfx.version.VersionChecker (in unnamed module @0x264cce0a) cannot access class com.sun.javafx.runtime.VersionInfo (in module javafx.base) because module javafx.base does not export com.sun.javafx.runtime to unnamed module @0x264cce0a
        at impl.org.controlsfx.version.VersionChecker.<clinit>(VersionChecker.java:50)
        at org.controlsfx.control.ControlsFXControl.<init>(ControlsFXControl.java:35)
        at org.controlsfx.control.StatusBar.<init>(StatusBar.java:82)
        at anywheresoftware.b4j.objects.StatusBarWrapper.innerInitialize(StatusBarWrapper.java:55)
        at anywheresoftware.b4j.objects.NodeWrapper.Initialize(NodeWrapper.java:95)
        at b4j.example.main._appstart(main.java:361)
        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:566)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
        at anywheresoftware.b4a.BA.raiseEvent(BA.java:95)
        at b4j.example.main.start(main.java:37)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
        at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
        at java.base/java.lang.Thread.run(Thread.java:834)


D:\ERP2_MQTT_LISTENER\Objects>pause
Premere un tasto per continuare . . .
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Also using integrated Packager11 the .exe not start correctly

What is the reason of above error, and how to correct?
Most likely, the EXE created had the same issue as post # 11. The problem is that this thread started going off track by trying to start the .jar file manually with Java 11, with Java 11 really not supporting running UI applications in a straightforward way as was available with Java 8. Quote from @Erel: "Java 11 doesn't support executable jars (for UI apps). You need to use B4JPackager11 to create an package with an embedded Java" (source: https://www.b4x.com/android/forum/t...ava-11-cannot-run-jar-file.105016/post-658007). You should probably have run the run_debug.bat batch file and used the error output from that to post your error that you were experiencing with your original issue (Java 11 EXE not executing properly).
 
Upvote 0

aminoacid

Active Member
Licensed User
Longtime User
Yes, It could be that java.exe takes it from the imposed path while other libraries from other directories
I also tried the system you recommended but I get another error
Any idea?


B4X:
D:\ERP2_MQTT_LISTENER\Objects>"C:\Program Files\Java\jdk-11.0.1\bin\java.exe" --module-path "C:\Program Files\Java\jdk-11.0.1\javafx\lib" --add-modules=javafx.controls,javafx.fxml,javafx.web -jar D:\ERP2_MQTT_LISTENER\Objects\erp2_mqtt_listener.jar D:\ERP2_MQTT_LISTENER\Objects\Erp2_Mqtt_Listener\
2021 09 07 14 23 21 285 - ================================================================================
2021 09 07 14 23 21 309 - Main.AppStart
main._appstart (java line: 361)
java.lang.IllegalAccessError: class impl.org.controlsfx.version.VersionChecker (in unnamed module @0x264cce0a) cannot access class com.sun.javafx.runtime.VersionInfo (in module javafx.base) because module javafx.base does not export com.sun.javafx.runtime to unnamed module @0x264cce0a
        at impl.org.controlsfx.version.VersionChecker.<clinit>(VersionChecker.java:50)
        at org.controlsfx.control.ControlsFXControl.<init>(ControlsFXControl.java:35)
        at org.controlsfx.control.StatusBar.<init>(StatusBar.java:82)
        at anywheresoftware.b4j.objects.StatusBarWrapper.innerInitialize(StatusBarWrapper.java:55)
        at anywheresoftware.b4j.objects.NodeWrapper.Initialize(NodeWrapper.java:95)
        at b4j.example.main._appstart(main.java:361)
        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:566)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
        at anywheresoftware.b4a.BA.raiseEvent(BA.java:95)
        at b4j.example.main.start(main.java:37)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
        at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
        at java.base/java.lang.Thread.run(Thread.java:834)


D:\ERP2_MQTT_LISTENER\Objects>pause
Premere un tasto per continuare . . .


Run the Command Prompt as Administrator.

Make sure that your paths are correct. Also see the link below. It make it much easier to run a Java11 jar file from the command line when you define the paths as environment variables and create a BAT file. Run the BAT file as Administrator.

 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
create a BAT file. Run the BAT file as Administrator.
You (plural) realize that the packager created a batch file already that runs the app from the command line? It’s called run_debug.bat
 
Upvote 0

aminoacid

Active Member
Licensed User
Longtime User
You (plural) realize that the packager created a batch file already that runs the app from the command line? It’s called run_debug.bat

Did not know that.
However to run the JAR file from the command line, you don't need to run the packager. Just compile the JAR and run it as specified in my previous post. Works like a charm for me. I have both the Java8 and Java11 JDK installed and compile for one or the other using the #JavaCompilerPath attribute. Then run it for testing purposes directly from the CMD line.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
I have both the Java8 and Java11 JDK installed and compile for one or the other using the #JavaCompilerPath attribute. Then run it for testing purposes directly from the CMD line.
If you're super lazy like myself, then you have a batch file figure out which Java version to use to run a particular .jar file. See: https://www.b4x.com/android/forum/t...8-or-11-via-batchfile-windows.106431/#content . Note: You may need to adapt it to handle cases such as encountered in post #11 of this thread.
 
Upvote 0
Top