Setting JAVA_HOME Environment Variable on Mac OS X 10.9
New to MacBook Pro and Java, you're facing challenges setting the JAVA_HOME environment variable. Despite consulting various guides, you've encountered obstacles with file editing and error messages.
Step-by-Step Guide to Setting JAVA_HOME in Mac OSX Environment:
Identify Your Shell: Determine if you're using bash or zsh. Run the following command:
echo $SHELL
Update Shell Configuration File:
For bash:
echo export "JAVA_HOME=$( /usr/libexec/java_home )" >> ~/.bash_profile
For zsh:
echo export "JAVA_HOME=$( /usr/libexec/java_home )" >> ~/.zshrc
Restart Your Shell: Type the following command to restart your shell:
exec $SHELL
Verify JAVA_HOME: Run this command to check if JAVA_HOME is set correctly:
echo $JAVA_HOME
Specify JDK Version (Optional): If you have multiple JDK versions installed, use the -v flag in java_home to specify the desired version:
echo export "JAVA_HOME=$( /usr/libexec/java_home -v 1.7 )" >> ~/.bash_profile
Resolving Terminal Errors:
The above is the detailed content of How Do I Set the JAVA_HOME Environment Variable on My Mac OS X 10.9?. For more information, please follow other related articles on the PHP Chinese website!