Java 22

peacemaker

Expert
Licensed User
Longtime User
In whole the question - why is it not good to use some latest Java SDK with B4X ?
Is it not the best (latest improved\fixed errors) if to update the SDK files set ?

Anyway, Java version 22 is detected not correct as 8 (v.18, 19 are detected correctly). And JavaFX is "not visible" (sure, /javafx folder is here).
B4J Version: 10.00
Parsing code. (1.22s)
Java Version: 8
Building folders structure. (0.18s)
Running custom action. (0.12s)
Compiling code. (1.49s)
Compiling layouts code. (0.05s)
Organizing libraries. (0.00s)
Compiling generated Java code. Error
src\peacemaker\orionlab\main.java:7: error: package javafx.application does not exist
public class main extends javafx.application.Application{
^
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
only showing the first 1 errors, of 325 total; use -Xmaxerrs if you would like to see more

javac 22
 
Last edited:

tchart

Well-Known Member
Licensed User
Longtime User
In whole the question - why is it not good to use some latest Java SDK with B4X ?
Is it not the best (latest improved\fixed errors) if to update the SDK files set ?

Anyway, Java version 22 is detected not correct as 8 (v.18, 19 are detected correctly). And JavaFX is "not visible" (sure, /javafx folder is here).

I have no problem with latest versions, the problem is with non-LTS version. They have a very limited lifespan. Java 22 is only supported until September 2024 - https://www.oracle.com/java/technologies/java-se-support-roadmap.html

Besides that there are usually problems with new releases that may never be resolved since support will end very promptly.

e.g. https://www.theverge.com/2024/3/17/...acos-sonoma-14-4-on-apple-silicon-breaks-java

Imagine your app becomes very popular and then a bug/vulnerability is discovered in the JRE you distributed. Then it becomes an admin nightmare for you.
 

mcqueccu

Well-Known Member
Licensed User
Longtime User
In whole the question - why is it not good to use some latest Java SDK with B4X ?
Is it not the best (latest improved\fixed errors) if to update the SDK files set ?

Anyway, Java version 22 is detected not correct as 8 (v.18, 19 are detected correctly). And JavaFX is "not visible" (sure, /javafx folder is here).
Perhaps you should visit this thread post #2: https://www.b4x.com/android/forum/threads/update-openjdk.140167/#post-887747
That is the structure of the JDK Setup

You can also use this to point to the java directory
B4X:
#JavaCompilerPath: 18, C:\java\jdk-18\bin\javac.exe
 

Daestrum

Expert
Licensed User
Longtime User
Java 22 runs fine, but you MUST add the line below if you want to write a UI app as @mcqueccu pointed out.
B4X:
#JavaCompilerPath 22, C:/java22/bin/javac.exe

I currently use java 14 - for B4R
java 21(LTS) and java 22 (just to try new features out)
 

peacemaker

Expert
Licensed User
Longtime User
just to try new features out

It is the initial reason of the question: what new\better features we obtain in B4X projects if to update the JDK version ?
 

Sagenut

Expert
Licensed User
Longtime User
It is the initial reason of the question: what new\better features we obtain in B4X projects if to update the JDK version ?
You could benefit from some bug fix or corrected vulnerability.
But if latest Java contain even new functionalities you will not benefit of them until B4A will be upgraded to use them.
I think it should work in this way.
But as told before, better to stick to LTS version for better support.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
But if latest Java contain even new functionalities you will not benefit of them until B4A will be upgraded to use them.
Not exactly correct.
1. We are talking about B4J here.
2. B4J doesn't need to be upgraded to use new features of Java. Like any native API, it should be called with a new library or JavaObject or inline Java.
 

peacemaker

Expert
Licensed User
Longtime User
Seems, clear: B4X compilers, i think, use some fixed code patterns to implement functions, and they will not be changed until Erel may edit the IDE code.
So, benefit is just for bug fixes from new SDK only.
 
Top