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:

  1. Open the Terminal application.
  2. 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.

  1. Run the following command to open the ~/.bash_profile file in a text editor:
open -e ~/.bash_profile
  1. 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
  1. Save the file and exit the text editor.

  2. 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.