B4J Question [SOLVED]Java 21 Environment

bdunkleysmith

Active Member
Licensed User
Longtime User
I believe I've downloaded "the three pieces and put them in the right place" to create a Java 21 environment as per this post by @Erel in order to confirm updating from Java 19 to Java 21 doesn't eliminate a problem I'm encountering with an app, but something's not quite right.

Firstly when I compile the app, it says Java Version: 8 as per below, whereas under Java 19 indeed it says Java Version: 19:

1747401916739.png


Does this indicate the contents and/or structure of the "three pieces" is wrong?

After compilation the app runs and my log suggests it's running in a Java 19 environment, but when I click on a button to load a video into MediaView, the following fatal error is thrown:

BDSSynergyPlayerBoard V21 - Ringwood started at 16/5/2025 23:15:18
Java version: 21.0.7
Host Address: 192.168.0.22
main._btnloadvideo_click (java line: 2337)
java.lang.ClassCastException: class java.lang.UnsatisfiedLinkError cannot be cast to class java.lang.Exception (java.lang.UnsatisfiedLinkError and java.lang.Exception are in module java.base of loader 'bootstrap')
at anywheresoftware.b4a.BA.setLastException(BA.java:399)
at b4j.example.main._btnloadvideo_click(main.java:2337)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.BA$1.run(BA.java:236)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
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:184)
at java.base/java.lang.Thread.run(Thread.java:1583)

Any guidance would be appreciated or ideally if someone has a complete zip of the "three pieces" for a functional Java 21 environment, I'd appreciate a link to it.
 

aeric

Expert
Licensed User
Longtime User
Try read this thread:
 
Upvote 0

bdunkleysmith

Active Member
Licensed User
Longtime User
Thanks @aeric, but everything's working fine for Java 19.0.2. I am trying to create a Java 21 environment and there appears to be many sources for the various components and depending on the source, I either have the errors noted above or even this one where I can't even compile the app

1747404704612.png


As I said above, why does it say Java Version: 8 even though I've pointed to javac.exe in the Java21 folder structure:

I downloaded openjdk-21_windows-x64_bin.zip, the 21 GA (build 21+35) from https://jdk.java.net/archive/ then openjfx-21.0.7_windows-x64_bin-sdk.zip and openjfx-21.0.7_windows-x64_bin-jmods.zip from https://gluonhq.com/products/javafx/, and arranged them in the folder structure specified in the other post I referenced.

I assume the javafx and javafx-mods files are not compatible with the openjdk file.

It would be nice just to be able to download a single zip for a Java 21 package just like the link on the B4J product page allows download of the Java 19 one.
 

Attachments

  • 1747404782370.png
    1747404782370.png
    15.7 KB · Views: 24
  • 1747405534613.png
    1747405534613.png
    18.5 KB · Views: 24
Upvote 0

teddybear

Well-Known Member
Licensed User
You need to add the #JavaCompilerPath:21, javacpath(java21) in Main.
 
Upvote 0

bdunkleysmith

Active Member
Licensed User
Longtime User
Thank you @aeric and @teddybear.

Indeed adding

B4X:
#JavaCompilerPath: 21, C:/Java/jdk-21.0.7/bin/javac.exe

results in Java Version: 21 being shown and the app compiling/running without error.

1747438996372.png


My understanding was that adding #JavaCompilerPath just overrode the path selected in the Paths Configuration dialog box, however it seems for at least Java 21, explicit definition using #JavaCompilerPath: is required.

So why is this required for Java 21 and yet I have not had to include #JavaCompilerPath: 19, C:\Java19\jdk-19.0.2\bin\javac.exe when using Java 19, but just point to the appropriate javac.exe? Perhaps the Java 19 package provided by @Erel contains something which downloading the "three pieces" from elsewhere doesn't.

Again thanks for the assistance - I just love the support users provide via this Forum, but unfortunately moving from from Java 19 to Java 21 still doesn't fix my random video errors using MediaView under Win11.
 
Upvote 0
Top