Change the Java version in macOS

Photo by Thoa Ngo on Unsplash
/usr/libexec/java_home -V
java -version
by giphy

Permanently change the java version 🍎

/Library/Java/JavaVirtualMachines/jdk-11.0.15.1.jdk/Contents/Home.
open -t .zprofile
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.15.1.jdk/Contents/Home
java -version
by giphy

Temporarily change the java version ☕

export JAVA_HOME=`/usr/libexec/java_home -v <DESIRED JAVA VERSION>`
export JAVA_HOME=`/usr/libexec/java_home -v 17.0.3.1`

Conclusion ✌

--

--

Software Engineer | WSO2

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store