How to set JAVA_HOME environment variable on Mac OS X 10.9?
To set the JAVA_HOME
environment variable on Mac OS X 10.9 (Mavericks), you can follow these steps:
- Open the Terminal application.
- Run the following command to determine the path to your JDK installation:
/usr/libexec/java_home
This command will output the path to the current JDK installation, such as /Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home
.
- Run the following command to open the
~/.bash_profile
file in a text editor:
open -e ~/.bash_profile
- Add the following line to the file, replacing
/path/to/jdk
with the path you obtained in step 2:
export JAVA_HOME=/path/to/jdk
Save the file and exit the text editor.
Run the following command to apply the changes:
source ~/.bash_profile
You should now be able to use the JAVA_HOME
environment variable in your terminal sessions.
I hope this helps! Let me know if you have any questions.