Last active
September 23, 2018 13:58
-
-
Save yauhen-info/3e5e8f6cd38a583bb927c3d4cfbb22df to your computer and use it in GitHub Desktop.
JDK version switch on MacOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 whenever 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. | |
____ | |
courtesy of https://www.kevinhooke.com/2017/10/05/switching-java-versions-on-mac-os/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment