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:


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

Posted on Jun 6, 2024 2:45 AM

Reply
Question marked as Top-ranking reply

Posted on Jun 6, 2024 10:58 AM

Jpegorino wrote:

That would've made sense why - I didn't use homebrew but I guess it's the same story with sdkman (The "Homebrew" reported by `/usr/libexec/java_home -V` is just read from the Info.plist file I made manually following link 2 instructions - the poster there says that the 'string' values are arbitrary, so I didn't change).

I don't know what's going on there.


It's the same general problem. Nobody wants to do the work to build decent apps and support them. I don't know what sdkman is. Perhaps it is Java built with Homebrew. Or perhaps it is just some other internet instructions that typically assume everyone is using Homebrew.

I tried again with version 22 from Oracle (https://www.oracle.com/uk/java/technologies/downloads/#jdk22-mac) both via the .tar and the dmg, restarting after install both times. The downloaded Java 22 still isn't being used as my default for GUI applications.

Again. Same problem. Hasn't changed in 25 years. If you want to dive head first into the deep end of Java, you can do that. You can configure multiple Java installations and switch between them. Given that someone else has likely just tossed you into the deep end, you may have no choice now.


I don't know. If I need to test something like this in Java, I'll do it in a VM. 😄 I'm sure I only have one Java here.

I did also download Mysqlworkbench though and that seems to run, so I perhaps if it could be just the apps I'm using?

Could be. As I said above. Same problem. Some academic hacked up a Mac app in 2007 and hasn't touched it since. More likely, said academic's grad student did the hacking. Maybe that survived the previous architecture shift to Intel. But now we've changed again to Apple Silicon.

Specifically, it's these I can't load with the oracle Java 22:
https://www.sanger.ac.uk/tool/artemis/
http://tree.bio.ed.ac.uk/software/figtree/

At least with Java, there's an escape hatch. All you have to do is download the Linux versions of each of these. Java is cross-platform, so it will run. Complex apps like this typically need complex environments. So they will typically have some startup scripts that you will need to use.


For these apps, I was able to run FigTree just by doing "java -jar figtree.jar". Artemis was more complicated. I had to run the top-level "./art" tool, which setup the environment and then ran the appropriate jar file. I guess they're working. Hard for me to tell. The GUIs definitely come up and are functional.


But regardless, if you just pretend like you're on Linux, everything should work as it would on Linux. It's very unlikely that Linux Java apps would have any platform-specific binary code. That's the problem on the Mac. Those Mac binaries are expecting something really specific about Mac Java from many years ago.

With the oracle 22, I now have these settings:
```
jgorzyns@S31-D9502L5V ~ % java --version
java 22.0.1 2024-04-16
Java(TM) SE Runtime Environment (build 22.0.1+8-16)
Java HotSpot(TM) 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)
jgorzyns@S31-D9502L5V ~ % /usr/libexec/java_home -V
Matching Java Virtual Machines (1):
22.0.1 (arm64) "Oracle Corporation" - "Java SE 22.0.1" /Library/Java/JavaVirtualMachines/jdk-22.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk-22.jdk/Contents/Home
jgorzyns@S31-D9502L5V ~ % head .zshrc
# install software
source "$HOME/.sdkman/bin/sdkman-init.sh"
# java configuration
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH

None of that should really matter. I tested all of these with no changes and no environment settings whatsoever. But it's possible that "sdkman-init.sh" could be some crazy script that will break everything else. I don't know. I think you only need JAVA_HOME for actually building JAVA apps from source.

4 replies
Question marked as Top-ranking reply

Jun 6, 2024 10:58 AM in response to Jpegorino

Jpegorino wrote:

That would've made sense why - I didn't use homebrew but I guess it's the same story with sdkman (The "Homebrew" reported by `/usr/libexec/java_home -V` is just read from the Info.plist file I made manually following link 2 instructions - the poster there says that the 'string' values are arbitrary, so I didn't change).

I don't know what's going on there.


It's the same general problem. Nobody wants to do the work to build decent apps and support them. I don't know what sdkman is. Perhaps it is Java built with Homebrew. Or perhaps it is just some other internet instructions that typically assume everyone is using Homebrew.

I tried again with version 22 from Oracle (https://www.oracle.com/uk/java/technologies/downloads/#jdk22-mac) both via the .tar and the dmg, restarting after install both times. The downloaded Java 22 still isn't being used as my default for GUI applications.

Again. Same problem. Hasn't changed in 25 years. If you want to dive head first into the deep end of Java, you can do that. You can configure multiple Java installations and switch between them. Given that someone else has likely just tossed you into the deep end, you may have no choice now.


I don't know. If I need to test something like this in Java, I'll do it in a VM. 😄 I'm sure I only have one Java here.

I did also download Mysqlworkbench though and that seems to run, so I perhaps if it could be just the apps I'm using?

Could be. As I said above. Same problem. Some academic hacked up a Mac app in 2007 and hasn't touched it since. More likely, said academic's grad student did the hacking. Maybe that survived the previous architecture shift to Intel. But now we've changed again to Apple Silicon.

Specifically, it's these I can't load with the oracle Java 22:
https://www.sanger.ac.uk/tool/artemis/
http://tree.bio.ed.ac.uk/software/figtree/

At least with Java, there's an escape hatch. All you have to do is download the Linux versions of each of these. Java is cross-platform, so it will run. Complex apps like this typically need complex environments. So they will typically have some startup scripts that you will need to use.


For these apps, I was able to run FigTree just by doing "java -jar figtree.jar". Artemis was more complicated. I had to run the top-level "./art" tool, which setup the environment and then ran the appropriate jar file. I guess they're working. Hard for me to tell. The GUIs definitely come up and are functional.


But regardless, if you just pretend like you're on Linux, everything should work as it would on Linux. It's very unlikely that Linux Java apps would have any platform-specific binary code. That's the problem on the Mac. Those Mac binaries are expecting something really specific about Mac Java from many years ago.

With the oracle 22, I now have these settings:
```
jgorzyns@S31-D9502L5V ~ % java --version
java 22.0.1 2024-04-16
Java(TM) SE Runtime Environment (build 22.0.1+8-16)
Java HotSpot(TM) 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)
jgorzyns@S31-D9502L5V ~ % /usr/libexec/java_home -V
Matching Java Virtual Machines (1):
22.0.1 (arm64) "Oracle Corporation" - "Java SE 22.0.1" /Library/Java/JavaVirtualMachines/jdk-22.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk-22.jdk/Contents/Home
jgorzyns@S31-D9502L5V ~ % head .zshrc
# install software
source "$HOME/.sdkman/bin/sdkman-init.sh"
# java configuration
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH

None of that should really matter. I tested all of these with no changes and no environment settings whatsoever. But it's possible that "sdkman-init.sh" could be some crazy script that will break everything else. I don't know. I think you only need JAVA_HOME for actually building JAVA apps from source.

Jun 6, 2024 8:59 AM in response to etresoft

Thanks etresoft,

That would've made sense why - I didn't use homebrew but I guess it's the same story with sdkman (The "Homebrew" reported by `/usr/libexec/java_home -V` is just read from the Info.plist file I made manually following link 2 instructions - the poster there says that the 'string' values are arbitrary, so I didn't change).

I tried again with version 22 from Oracle (https://www.oracle.com/uk/java/technologies/downloads/#jdk22-mac) both via the .tar and the dmg, restarting after install both times. The downloaded Java 22 still isn't being used as my default for GUI applications. I did also download Mysqlworkbench though and that seems to run, so I perhaps if it could be just the apps I'm using?

Specifically, it's these I can't load with the oracle Java 22:

https://www.sanger.ac.uk/tool/artemis/

http://tree.bio.ed.ac.uk/software/figtree/

With the oracle 22, I now have these settings:

```

jgorzyns@S31-D9502L5V ~ % java --version

java 22.0.1 2024-04-16

Java(TM) SE Runtime Environment (build 22.0.1+8-16)

Java HotSpot(TM) 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)

jgorzyns@S31-D9502L5V ~ % /usr/libexec/java_home -V

Matching Java Virtual Machines (1):

22.0.1 (arm64) "Oracle Corporation" - "Java SE 22.0.1" /Library/Java/JavaVirtualMachines/jdk-22.jdk/Contents/Home

/Library/Java/JavaVirtualMachines/jdk-22.jdk/Contents/Home

jgorzyns@S31-D9502L5V ~ % head .zshrc

# install software

source "$HOME/.sdkman/bin/sdkman-init.sh"

# java configuration

export JAVA_HOME=$(/usr/libexec/java_home)

export PATH=$JAVA_HOME/bin:$PATH

```

Cheers!


Jun 6, 2024 4:22 AM in response to Jpegorino

Java and Homebrew? That's got to hurt.


As a test, I downloaded the latest version of Java 22 from Oracle and installed. Then I had to find an app that actually required Java. I found Mysqlworkbench. I verified that I wasn't located in any of their disallowed countries or a member of any disallowed group and downloaded it. It fired right up.


I don't know what to tell you. Seems to work fine here. Same old story. Yet another homebrew problem.

Jun 7, 2024 3:37 AM in response to etresoft

Thanks again etresoft,


I did know that I could get these working the linux way from the terminal but I figured there must be a way to run apps needing Java > 8 through the GUI on Sonoma!


It makes sense though if it's just apps where the developers haven't kept adapting them for newer system changes, no doubt it's not worth the time/effort to do that without a dedicated budget.


Cheers

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to use latest java version for GUI applications in OSX Sonoma?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.