Try jenv
util to use different versions for different apps: link to how-to
In general, you should download all the versions you need, then you've gotta do the following:
- install jenv (this step require any brew instance on your mac, if you don't have one, look here):
brew install jenv
add these lines to your
.bash_profile
, script will init jenv util:# Init jenv if which jenv > /dev/null; then eval "$(jenv init -)"; fi
register all jdk in **jenv:
jenv add /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/ jenv add /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/
- run this to list all registered jdk:
jenv versions
One with the asterisk is the current version.
- this command'll set global version:
jenv global oracle64-1.7.0.79
- and by this one you can set local versions in any project folders you need:
cd <my project> jenv local oracle64-1.8.0.66