Currently (April 17, 2019) the latest version of java is 12.
$ brew install jenv
Add the following to .bash_profile and pass it through the path.
#Pass through jenv's PATH
export JENV_ROOT="$HOME/.jenv"
if [ -d "${JENV_ROOT}" ]; then
export PATH="$JENV_ROOT/bin:$PATH"
eval "$(jenv init -)"
fi
There is also a method to install with brew cask, but in the current environment it was not possible to install from brew, so install from Oracle.
I installed 12,10,8 this time, so I will explain it on that assumption.
$ /usr/libexec/java_home -V
When you run the above command, the installed JDK versions will be listed.
In my case, the command is executed and returned as follows.
12, x86_64: "Java SE 12" /Library/Java/JavaVirtualMachines/jdk-12.jdk/Contents/Home
10.0.2, x86_64: "Java SE 10.0.2" /Library/Java/JavaVirtualMachines/jdk10.0.2.jdk/Contents/Home
1.8.0_202, x86_64: "Java SE 8"/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
You will need the part displayed as /Library… jdk-12.jdk / Contents / Home later. ・
$ jenv add /Library...jdk-12.jdl/Contents/Home
Enter the above part after `jenv add`
like, and register it in jenv.
$ jenv versions
The java version registered in jenv is displayed in a list with the command of.
$ jenv global 12
$ jenv rehash #May not be needed
$jenv gobal [version]
After the
$jenv rehash
In my case, the version did not switch.
$ jenv local 12
$jenv local [version]
Change with
Whether it can be changed
java -version
So, check it, and if the changes are reflected, it's okay! !!
Recommended Posts