Switch Java Version Mac Sierra
Hello Mac User! This is Tutorial Show Step-by-Step How-to Switch Java Version Mac Sierra Command Line.
Furthermore the Tutorial Include also Links on How-to Download and Install the Oracle Official Java Development Kit for Mac OS X.
-
So Open a Command Line Terminal Window
(Press “Enter” to Execute Commands) -
Then Edit the Bash Shell Config Environment
nano $HOME/.bashrc
Copy & Append inside this is Function:
alias java_ls='/usr/libexec/java_home -V 2>&1 | grep -E "\d.\d.\d[,_]" | cut -d , -f 1 | colrm 1 4 | grep -v Home' function java_use() { export JAVA_HOME=$(/usr/libexec/java_home -v $1) export PATH=$JAVA_HOME/bin:$PATH java -version }
Ctrl+x to Save & Exit from nano Editor 😉
-
Load the New Environment
bash
-
Then to Easy Switch the Java Version
java_use 1.[x]
Example:
java_use 1.8
How-to Install the Oracle Java JDK 7+ on Mac OS X: