How to configure JDK environment variables on MacOS

1 Enter the command to see whether the JDk environment variable is configured: echo $JAVA_HOME

If nothing is output, it means it is not configured.

2 Enter the command to edit sudo vim ~/.bash_profile

Then press i to enter editing mode and paste the following code. Note: The path behind JAVA_HOME needs to be changed to your own version. Esc to exit editing, enter: qw! save

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_361.jdk/Contents/Home CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:. PATH=$JAVA_HOME/bin:$PATH: .
export JAVA_HOME
export PATH export CLASSPATH
 3 Refresh the command to make the configuration file take effect

source ~/.bash_profile

4 Enter the view command:

echo $JAVA_HOME and check again to see if it was successful.

Guess you like

Origin blog.csdn.net/m0_62567916/article/details/133526184