Switch from windows to mac for development, and record the configuration environment for your reference;
1. Download jdk
地址:Java Downloads | Oraclehttp://www.oracle.com/technetwork/java/javase/downloads/index.html
When I downloaded, I had to log in before downloading, so I found this to download and install directly
2. Install the downloaded jdk, and continue to the next step until the end
3. Verify whether the installation is successful
Open the terminal and enter java -version
The output is the version information, indicating that the installation has been successful;
4. Configure the java environment
Open the java installation path Mac default path is /Library/Java/JavaVirtualMachines/
Hold down the command key and add a space, search for /Library/Java/JavaVirtualMachines/jdk1.8.0_321.jdk/Contents
open this folder
Right click on the Home folder - create a new terminal window at the folder location
Enter the command sudo vim /etc/profile, and then you need to enter the mac password
After entering the password, the profile information will be printed out
Press i to enter insert and enter edit mode, paste the following text into the next line of fi
JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home"
export JAVA_HOME
CLASS_PATH="$JAVA_HOME/lib"
PATH=".$PATH:$JAVA_HOME/bin"
Note that the jdk****** in the path must be consistent with the java -version, then press esc to exit the editing mode, then enter the command :wq!, and press Enter to save successfully.
5. Enter source /etc/profile to make the setting take effect immediately.
6. Check whether the java environment is configured successfully. Enter the command echo $JAVA_HOME, and the output is as follows, indicating that java has been configured successfully.
/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home
It's not easy to code, please give it a thumbs up before leaving~