how to set the java_home in mac

‮sptth‬://www.lautturi.com
how to set the java_home in mac

To set the JAVA_HOME environment variable in macOS, follow these steps:

  1. Open the Terminal app.
  2. Type the following command to open the bash_profile file in a text editor:
nano ~/.bash_profile
  1. Scroll to the bottom of the file and add the following line, replacing /path/to/java with the path to the Java installation directory:
export JAVA_HOME=/path/to/java
  1. Press Ctrl + O to save the file and Ctrl + X to exit the text editor.

  2. Reload the bash_profile file by typing the following command:

source ~/.bash_profile
  1. To verify that the JAVA_HOME environment variable has been set correctly, type the following command:
echo $JAVA_HOME

This should print the path to the Java installation directory that you set in the bash_profile file.

Note: The bash_profile file is a hidden file in your home directory that is executed every time you start a new Terminal session. You can use the bash_profile file to set environment variables, such as JAVA_HOME, that you want to be available every time you start a new Terminal session.

Created Time:2017-11-01 20:43:01  Author:lautturi