Steps to create a Java development environment using jenv on Mac.
Install 8 and 10
$ brew tap caskroom/versions
# java 8
$ brew cask install java8
# java 10 (newest version)
$ brew cask install java
$ git clone https://github.com/gcuisinier/jenv.git ~/.jenv
Add the following to .bash_profile
.
# jenv
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"
Read .bash_profile
.
$ source .bash_profile
Check the version of Java installed.
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
10.0.2, x86_64: "Java SE 10.0.2" /Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home
1.8.0_181, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home
Add the Java PATH installed in jenv. If you upgrade Java, add it again.
$ jenv add /Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home
$ jenv add /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home
Use the specified version globally.
$ jenv global 10.0.2
Use the specified version locally (that directory).
$ jenv local 10.0.2
$ cd $(jenv root)
$ git pull
Recommended Posts