How to change the JDK version on MacOSX

First, find out what JDK version that is installed on your computer. To do this, run the following command in the terminal.

/usr/libexec/java_home -V

If you have any JDK installed, the output will be something simular to this.

Matching Java Virtual Machines (3):
    11.0.1, x86_64:	"Java SE 11.0.1"	/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home
    1.8.0_202, x86_64:	"Java SE 8"	/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
    1.8.0_51, x86_64:	"Java SE 8"	/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home

Then, if your want to use the Java 1.8, then you should execute.

export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_202`

Then you can check if the changes have been taking into effect by checking the java version:

java -version

Teis Lindemark

Software developer, beer brewer and AGENT backer

Bergen, Norway https://teilin.net

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer’s view in any way.