How to use latest java version for GUI applications in OSX Sonoma?
I need to run java applications that require Java version > 8 on a MacBook Pro (Apple M3 Pro) runnning Sonoma 14.4. As the latest supported version available through Oracle is version 8, I installed a later version in the terminal via sdkman. However, I cannot seem to set it as the default version for Java GUI applications.
I've followed instructions from a number of forums online but to no avail:
- https://discussions.apple.com/thread/255283838?sortBy=best
- https://stackoverflow.com/questions/76523553/how-to-make-usr-libexec-java-home-find-jdk-installed-using-sdkman-on-macos/76523554#76523554
- https://stackoverflow.com/questions/21964709/how-to-set-or-change-the-default-java-jdk-version-on-macos?page=1&tab=scoredesc#tab-top
After troubleshooting, I have now added the following lines to my .zshrc:
```
# java configuration
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH
```
and here are the details for other relevant settings, as suggested on the forums:
```
jgorzyns@S31-D9502L5V Contents % java --version
openjdk 17.0.10 2024-01-16
OpenJDK Runtime Environment Temurin-17.0.10+7 (build 17.0.10+7)
OpenJDK 64-Bit Server VM Temurin-17.0.10+7 (build 17.0.10+7, mixed mode)
jgorzyns@S31-D9502L5V Contents % /usr/libexec/java_home -V
Matching Java Virtual Machines (1):
9999 (arm64) "Homebrew" - "SDKMAN Current JDK" /Library/Java/JavaVirtualMachines/sdkman-java-Temurin-17.0.10+7/Contents/Home
/Library/Java/JavaVirtualMachines/sdkman-java-Temurin-17.0.10+7/Contents/Home
jgorzyns@S31-D9502L5V Contents % ls /Library/Java/JavaVirtualMachines/sdkman-java-Temurin-17.0.10+7/Contents/
Home Info.plist
jgorzyns@S31-D9502L5V Contents % cat /Library/Java/JavaVirtualMachines/sdkman-java-Temurin-17.0.10+7/Contents/Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>sdkman.current</string>
<key>CFBundleName</key>
<string>SDKMAN Current JDK</string>
<key>JavaVM</key>
<dict>
<key>JVMPlatformVersion</key>
<string>9999</string>
<key>JVMVendor</key>
<string>Homebrew</string>
<key>JVMVersion</key>
<string>9999</string>
</dict>
</dict>
</plist>
```
It is my understanding that the system settings pane to configure Java no longer a supported feature in later Java versions, so I don't think there is any way to configure my java in the GUI?
I have also tried checking the GUI applications settings to see if I can easily set the location of the java version they use but without any luck.
Any help or advice would be greatly appreciated here!
Jamie
MacBook Pro 14″, 14.4