While running Java applications, sometimes you may have to set JAVA_HOME environment variable. Here are the instructions to quickly set JAVA_HOME on your MAC OS.
- Open Terminal
- To Confirm if you have Java
- Type command: "which java"
- Hit Enter/Return button
- The command should return something like this: /usr/bin/java
- To get location of Java (detailed steps are documents here)
- Type command: /usr/libexec/java_home
- Hit Enter/Return button
- The command should return something like this: /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
- To Set JAVA_HOME for single session
- Type command: export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
- Hit Enter/Return button
- Type command to verify: echo $JAVA_HOME
- To Set JAVA_HOME permanently
- Type command: vi ~/.bash_profile
- This will open bash_profile file
- Go to the end, and add following lines
- JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
- export JAVA_HOME;
- Save the file
- Restart Terminal
- Type command to verify: echo $JAVA_HOME
Comments
Post a Comment