- Open Terminal
- Confirm you have JDK by typing “which java”. It should show something like /usr/bin/java.
- Check you have the needed version of Java, by typing “java -version”.
- JAVA_HOME is essentially the full path of the directory that contains a sub-directory named bin which in turn contains the java
- For Mac OSX – it is /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home
- Set JAVA_HOME using this command in Terminal:
-
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home -
exportPATH=$PATH:$JAVA_HOME
-
- Lastly apply these changes by re-sourcing .bash_profile:
-
source ~/.bash_profile
-
- To verify if the PATH is set right :
- Open Terminal and Type : $JAVA_HOME/bin/java -version
- Should give output something as below :
java version “1.8.0_112”
Java(TM) SE Runtime Environment (build 1.8.0_112-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b16, mixed mode)
Abc-MacBook-Pro:~ Abc$ java version “1.8.0_112”
One thought on “Setting JAVA_HOME PATH on MAC”