B4J Question OpenJDK 17 or 19? JavaFX SDK 17?

aeric

Expert
Licensed User
Longtime User
I understand that the recommended version for B4J (current version 9.80) is OpenJDK 11.
Should I combine javafx17 with openjdk17?
Or can I leave open jdk11?

Better to use jdk11 or 14.


Note that you can use any version of OpenJDK you like. You just need to download the three pieces and put them in the right place:
- OpenJDK
- JavaFX SDK + jmods: https://gluonhq.com/products/javafx/

JavaFX SDK should be in javafx folder.
JavaFX jmods should be in javafx\javafx-jmods folder

So, is it a good time to use newer version?

If yes, version 17 or 19?
Do I need to choose OpenJDK 17 since JDK 17 is LTS version? and because JavaFX 17 is also LTS version?

Can I mix OpenJDK 19 with JavaFX SDK 17?

Does it have any effect to B4JPackager11?
 

peacemaker

Expert
Licensed User
Longtime User
I haven't test compiling under Linux
I have just started my server app project (via B4JBridge) on a remote Linux host by OpenJDK19 bundle - works OK as before with OpenJDK14.
(under Windows an UI app is also OK).
 
Last edited:
Upvote 0

tchart

Well-Known Member
Licensed User
Longtime User
Just wanted to point out that you should really only use LTS versions of Java Runtime (Long Term Support). Otherwise you might find the required JRE doesnt get security fixes any more.

Only Java 11 and 17 are LTS.

Java 11 is supported till 2026
Java 17 is supported till 2029

See here;
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
For JDK 17:

OpenJDK 17.0.2 (choose Windows / x64 zip and extracted as jdk-17.0.2 folder under C:\Java or your preferred directory)
Download: https://jdk.java.net/archive/

JavaFX 17.0.2 (extract the SDK to jdk-17.0.2 directory extracted above as javafx folder, jmods into this javafx directory as javafx-jmods)
Download: https://gluonhq.com/products/javafx/

1675849494403.png


1675849422950.png
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
OpenJDK 19.0.2 (choose Windows / x64 zip and extracted as jdk-19.0.2 folder under C:\Java)
Download: https://jdk.java.net/19/

JavaFX 19.0.2 (extract the SDK to jdk-19.0.2 directory extracted above as javafx folder, jmods into this javafx directory as javafx-jmods)
Download: https://gluonhq.com/products/javafx/

Optional step: copy the oldimpl folder from JDK 11 and paste inside the \javafx\lib\javafx.swing.jar (I made a backup)
to suppress a warning in B4J IDE logs

View attachment 138821

View attachment 138822
19 no longer available, tried 21, to no avail. Thanks for this heads up.
 
Upvote 0

CR95

Active Member
Licensed User
I would like to update my Java environment in order to use jGoogleMaps library (OpenJDK 19.0.2 + OpenJFX 17.0.6 mandatory)
https://www.b4x.com/android/forum/threads/jgooglemaps-library.56744/

As aeric said (#25), I installed OpenJDK 19.0.2 under Windows
Then, I downloaded openjfx-17.0.9_windows-x64_bin-sdk and openjfx-17.0.9_windows-x64_bin-jmods from https://gluonhq.com/products/javafx/

Following instruction from aeric was
extract the SDK to jdk-17.0.2 directory extracted above as javafx folder, jmods into this javafx directory as javafx-jmods)
BUT my "jdk-19.0.2" folder already contains a "javafx" directory and a "jmods" directory.

That seems wrong. Is that the good process ?

Additional question : after installing these 3 packages, do I have to create/modify environment variables (JAVA_HOME, PATH, PATH_TO_FX, PATH_TO_FX_MODS) as the repositories have been changed ?
 
Upvote 0

CR95

Active Member
Licensed User
@aeric
Thanks for the quick reply
I did not see that the jmods folder should be renamed in javafx-jmods. Thanks for your remark
But do you confirm that the downloaded "javafx-sdk-17.0.9" folder should be copied in the "javafx" folder of the SDK ?
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
@aeric
Thanks for the quick reply
I did not see that the jmods folder should be renamed in javafx-jmods. Thanks for your remark
But do you confirm that the downloaded "javafx-sdk-17.0.9" folder should be copied in the "javafx" folder of the SDK ?
Yes. Extract the content of the zip file. Do not use the file name as folder name.
You can check/compare the directory structure of Java 11.
 
Upvote 0

CR95

Active Member
Licensed User
@aeric
I am not sure that my previous jdk11 was correctly installed (I did not use JavaFx before)

I made as you said ! But nothing works !

the cmd java -version returns :
1704219203240.png

It seems that OpenJDK is correct (version 18.9) but openjdk is always on the previous jdk 11.
javafx -version returns that there is no javafx...

When I compile (B4J), the log says "Java Version : 8" although I change the path to the new adress of the java 19 compiler

Do you have any idea ?
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
@aeric
I am not sure that my previous jdk11 was correctly installed (I did not use JavaFx before)

I made as you said ! But nothing works !

the cmd java -version returns :
View attachment 149207
It seems that OpenJDK is correct (version 18.9) but openjdk is always on the previous jdk 11.
javafx -version returns that there is no javafx...

When I compile (B4J), the log says "Java Version : 8" although I change the path to the new adress of the java 19 compiler

Do you have any idea ?
You may have confused with the Java exe or msi version that you installed into Program Files.
You can ignore this "installed" Java. We don't use it for B4X.

Instead, use the JDK that you do "not installed".

In my case, I have unzip the file to C:\Java

1704223229341.png


To check the JDK version, you need execute the command from bin folder
1704223856391.png


I am not sure any way to check JavaFX version. Maybe you can open the javafx.properties file inside lib folder.
1704224129762.png
 
Upvote 0

CR95

Active Member
Licensed User
@aeric
One more time, thanks for your help.

My tree is strictly identical to yours excepted the name of the upper directory.
If I move to the"jdk-19.0.2/bin" directory, the cmd java -version returns a response strictly identical to yours.
If I check the javafx.properties file (as you), there is a difference. Yours is level 19 and mine is level 17
Debug.png

This is coherent as Erel said to use level 17 in :
https://www.b4x.com/android/forum/threads/jgooglemaps-library.56744/
I don't guess my issue come from this difference ?

I find another track to find my problem. If I compile a B4J program with the path to my "previous java", everything is fine and level of Java is correct in the compile window.
If I compile with the path to my "new java", the level of java is wrong (should be 19) and there is this javafx error. See photos

Debug2.png


Debug3.png



Do you have an idea what is wrong ?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
what is wrong ?
1) Try to use short folder names in the path to Java, up to 8 symbols
2) IMHO better to remove the environment variables (JAVA_HOME and others)
3) For ref: special symbol "!" is forbidden for using in any Java apps paths.
 
Last edited:
Upvote 0

CR95

Active Member
Licensed User
@peacemaker
Thanks for your help
I made your suggested changes (shorter path name, removing all system environment variables in windows) but problem is still there (Java 8 when starting to compile followed by "error: package javafx.application does not exist"). See my previous photo.

May be I should restart a new complete installation with jdk9 and java fx19 (same level) ?
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Have you tried adding the line (change to suit your version of java)
B4X:
#JavaCompilerPath: 21, C:/jdk-21/bin/javac.exe

To see if it compiles.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
@CR95 : Make sure you're running the latest version of B4J (this may resolve the compile time Java version issue)
 
Upvote 0
Top