5

I have in my .zshrc the following line which pick which JAVA_HOME it is

export JAVA_HOME=$(/usr/libexec/java_home -v '1.8*')

I used to only have AdoptOpenJdk, hence doing that can let me easily pick AdoptOpenJdk version 1.8

However, after installing Zulu, when I run java_home -V, I have the below

./java_home -V             
Matching Java Virtual Machines (2):
    1.8.0_282 (arm64) "Azul Systems, Inc." - "Zulu 8.52.0.23" /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home
    1.8.0_282 (x86_64) "AdoptOpenJDK" - "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

After that, now my JAVA_HOME which is running /usr/libexec/java_home -v '1.8*' to determined is pointing to Zulu open jdk.

How can I get it back to AdoptJDK by just using java_home command?

Elye
  • 53,639
  • 54
  • 212
  • 474

2 Answers2

0

Try using

'unset JAVA_HOME;export JAVA_HOME=$(/usr/libexec/java_home -v '1.8*')'
MaTriXy
  • 1,659
  • 1
  • 20
  • 27
0

I've used free this tool in the past, it allows you to switch between different Java environments. https://www.jenv.be/

Nick
  • 925
  • 1
  • 8
  • 13