Reputation: 197
I have oracle and adoptOpen's JDK installed.
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (3):
11.0.5, x86_64: "Java SE 11.0.5" /Library/Java/JavaVirtualMachines/jdk-11.0.5.jdk/Contents/Home
11.0.4, x86_64: "AdoptOpenJDK 11" /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
1.8.0_161, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home
In the past, i switched between jdk11 and jdk1.8 by using:
alias jdk11='export JAVA_HOME=`/usr/libexec/java_home -v11`'
alias jdk8='export JAVA_HOME=`/usr/libexec/java_home -v1.8`'
but I can't see how to select between the two jdk11 providers. java_home -v11
will always get me the Oracle path and the help/manpage do not show any option that I could use to differentiate them.
How can I tell java_home
that I want "AdoptOpenJDK 11" and not "Java SE 11"?
Upvotes: 1
Views: 127
Reputation: 807
java_home
does not seem to have a way to filter by provider / vendor.
I was able to filter the output of java_home -V
to get what you want.
For your particular example,
alias jdk11='export JAVA_HOME=`/usr/libexec/java_home -V 2>&1 > /dev/null | grep "OpenJDK 11" | sed -e "|.*/Library|/Library|"`'
Upvotes: 1
Reputation: 2105
Computer
> Properties
> Advanced System Settings
> Environment Variables
Upvotes: 1