Mac environment variable configuration (Java)

1. Open the terminal:

2. Enter the command: [/usr/libexec/java_home -V] to view the default jdk download address (the green underline is the default path of jdk) ( note ⚠️: the command line terminal is case-sensitive [-v is wrong, Must be uppercase -V])

 3. If it is the first time to configure environment variables, use the command: [touch .bash_profile] to create a .bash_profile hidden configuration file (if there is an existing configuration file, enter: [open -e .bash_profile]) to open as follows

4. Enter the following command: (Note ⚠️: The red font is the path of your own jdk found in step 2)

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home

PATH=$JAVA_HOME/bin:$PATH:.

CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.

export JAVA_HOME

export PATH

export CLASSPATH

】 

5. Close the terminal, the terminal will automatically save

6. Enter the command [source .bash_profile] to make the configuration take effect 

7. Enter [echo $JAVA_HOME] to display the path just configured

Guess you like

Origin blog.csdn.net/ng_elza/article/details/123529091