JAVA Home and macOS
I decided to take the leap a couple weeks ago and installed macOS Big Sur. I have had a couple small issues like the display not waking up from sleep and my JAVA IDE not rendering some text properly, but it seems pretty solid. There was one issue with my development tools related to the
JAVA_HOME settings and I wanted to document for future me.
In macOS you can run the following command in Terminal to list out all the different versions of JAVA installed.
$/usr/libexec/java_home -V Matching Java Virtual Machines (3): 12.0.1 (x86_64) “Oracle Corporation” - “OpenJDK 12.0.1” /Library/Java/JavaVirtualMachines/openjdk-12.0.1.jdk/Contents/Home 22.214.171.124 (x86_64) “Oracle Corporation” - “Java” /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home 1.8.0_211 (x86_64) “Oracle Corporation” - “Java SE 8” /Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home
You can then specify the active JAVA in Terminal by adding the following to your
.bash_profile and specifying the version to use.
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8.0_211)
I ran into an issue after the upgrade because the 126.96.36.199 plugin was new in the list and I had only specified version 1.8, so my
JAVA_HOME was getting set to the plugin instead of the JDK. After changing it from
1.8 to the more specific
1.8.0_211 I was back in business.