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?
 

Daestrum

Expert
Licensed User
Longtime User
I think using the later versions is good as a lot of the code has been optimized for faster performance.
But.... B4X won't let you use any new features (even in in line java) because of the hard-coded Target and Source switches, these basically limit the compiler to use features in the target/source version, which last time I looked was 11.

But I could be wrong regarding the Target/Source nowadays.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
It seems JavaFX 17 is no longer available for download.
See post #25

Then I tried OpenJDK 17.0.2 + JavaFX SDK 19.0.2.
Edit: It is working fine but I see a warning message.
It seems conflict occurs in jOkHttpUtils2 library.

B4X:
WARNING: package com.sun.javafx.embed.swing.oldimpl not in javafx.swing
Waiting for debugger to connect...
Program started.
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
But.... B4X won't let you use any new features (even in in line java) because of the hard-coded Target and Source switches, these basically limit the compiler to use features in the target/source version, which last time I looked was 11.
That's not true. You should be able to access all the underlying APIs.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
As I said I wasn't sure nowadays, as I haven't written anything for ages. Last time I tried with java 16 it still did not allow use of var.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Maybe @aeric can prepare his bundle of the updated files he used OK, and @Erel can publish it as the new beta-version for trial period ?
The community will test it with own projects, reporting about the result and ... if OK, later the bundle will be the new recommended one in the installation steps.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Maybe @aeric can prepare his bundle of the updated files he used OK, and @Erel can publish it as the new beta-version for trial period ?
The community will test it with own projects, reporting about the result and ... if OK, later the bundle will be the new recommended one in the installation steps.
I think Erel has his own ways to test which bundle works.

I am not expert in Java. So far I just tested to use the new versions downloaded from the recommended sites. Usually the latest version is better but LTS is more favorable.
I am using OpenJDK 19.0.2 + JavaFX 19.0.2. It is compiling and creating standalone package. šŸ¤”
If this combination work for me in my B4J projects I will keep it. For B4A maybe further tests are needed.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I am using OpenJDK 19.0.2 + JavaFX 19.0.2.
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

1675327409567.png


1675327803928.png
 
Last edited:
Upvote 0

aeric

Expert
Licensed User
Longtime User
Download 2 files (SDK and "jmods") ?

View attachment 138829
Yes. Follow Erel's instruction in post#2
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Can we use Preview features in B4J? I am getting error.

B4X:
B4J Version: 9.80
Parsing code.    (0.00s)
    Java Version: 19
Building folders structure.    (0.01s)
Compiling code.    (0.00s)
Compiling layouts code.    (0.00s)
Organizing libraries.    (0.00s)
Compiling generated Java code.    Error
B4J line: 18
End Sub
src\b4j\example\main.java:74: error: patterns in switch statements are a preview feature and are disabled by default.
      case String s && s.length() > 5 -> System.out.println(s.toUpperCase());
           ^
  (use --enable-preview to enable patterns in switch statements)
1 error
only showing the first 1 errors, of 5 total; use -Xmaxerrs if you would like to see more

1675335970299.png
 
Upvote 0
Top