Search code examples
javamacosversionopenj9

Changing MacOS java version, Eclipse OpenJ9


I am using MacOS BigSur, trying to change java version to v1.8 I have followed the instructions from this question but no results.

/usr/libexec/java_home -V commands outputs:

Matching Java Virtual Machines (1):
    1.8.0_292 (x86_64) "AdoptOpenJDK" - "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

But java --version command returns:

openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9)
Eclipse OpenJ9 VM AdoptOpenJDK-11.0.11+9 (build openj9-0.26.0, JRE 11 Mac OS X amd64-64-Bit Compressed References 20210421_957 (JIT enabled, AOT enabled)
OpenJ9   - b4cc246d9
OMR      - 162e6f729
JCL      - 7796c80419 based on jdk-11.0.11+9)

When I removed java completely from the OS following these instructions I would still get the same java --version output, but running /usr/libexec/java_home would return

The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

.zshrc file has JAVA_HOME set to /usr/libexec/java_home -v 1.8.0_265

Where can I find this java that is currently referenced with the java command, or where can I change that reference on the command?


Solution

  • There is a very easy way of managing JDK installations almost automatically using something like SDKMAN. I suggest you have a look at this, as it would greatly simplify the process of managing whatever is that you need to manage. Note that the solution work for both MacOS and Linux.