Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. Check the current version out of curiosity
- > /usr/libexec/java_home -V
- Expected result should be similar to
- Matching Java Virtual Machines (2):
- 9.0.4, x86_64: "Java SE 9.0.4" /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home
- 1.8.0_162, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home
- /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home
- 2. Update your .bash_profile with shortcuts to swith between versions easily:
- from whatever you are, go to you home dir
- > cd
- > vi .bash_profile
- add lines like:
- alias j9="export JAVA_HOME=`/usr/libexec/java_home -v 9`; java -version"
- alias j8="export JAVA_HOME=`/usr/libexec/java_home -v 1.8`; java -version"
- save and exit (in vi it's `:wq`)
- update your bash_profile with
- > source .bash_profile
- 3. You are ready to go.
Add Comment
Please, Sign In to add comment