Trying Java 19 in Xojo
Let's try the MBS Xojo Java Plugin for Xojo with Java 19.0.2. We go to the download page and pick the jdk-19_macos-aarch64_bin.dmg file from Oracle's download page.
We get the installer, run it and after it finishes, Java is installed. Let's try and open Terminal and run the
java --version
command to see what version we got:
java 19.0.2 2023-01-17 Java(TM) SE Runtime Environment (build 19.0.2+7-44) Java HotSpot(TM) 64-Bit Server VM (build 19.0.2+7-44, mixed mode, sharing)
The files are all installed into a folder in your /Library folder, e.g.
/Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home
so the libjvm.dylib is in that folder and we load it in our project here:
JavaVMMBS.SetLibraryPath("/Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home/lib/server/libjvm.dylib")
Put this before calling the JavaVMMBS constructor. You still pass version 1.4 there as this is the version of the jni API and this part of Java hasn't changed or 10 years. The later Java versions changed compiler and added framework classes, but didn't change the jni interface.
We can query java.version or os.version here:
When we run this, it shows the version 19.0.2 here for the java.version property. Please note that we had recently to update the .long() calls to .Int64Value() since Xojo deprecated the old calls. If the library isn't found and loaded, the application may fail and get killed by macOS for accessing Java.framework, which is the default way to load.
Please note that we have to check the platform used for macOS since running an example compiler for Intel with a Java library built for Apple Silicon. The application may just quit in that case or better repport an error.
We'll fix the Java.framework thing. Let us know if you have questions. The bug fixes for Java 19 on macOS comes into version 23.2.