Mac OS configures java environment variables to build a development environment

1. Open Terminal
Search in finder (this MAC) to find the terminal
2. Enter sudo vim /etc/profile after cdlouiedeAir:~ cdlouie$ (cdlouie is my computer username)
3. Enter the computer user name and password after the password, the password will not be displayed
4. Then press the i key anywhere to switch the editor status ("/etc/profile" [readonly] 16L, 369C) to INSERT (-- INSERT -- W10: Warning: Changing a readonly file) and position the cursor to the last line After fi, carriage return and line feed, insert the following code:
#Here are the environment variables of JAVA
JAVA_HOME=“Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/”CLASS_PATH=“$JAVA_HOME/lib”PATH=“.;$PATH:$JAVA_HOME/bin”
5. Press ESC again to exit the editing state
6. Press shift+colon, a colon will appear in the editor, then enter wq! Enter to save successfully.
7. Check, re-enter sudo vim /etc/profile to view, if the code just inserted is still saved successfully.
8. Note, the version of the inserted code jdk can be queried through the terminal command: java -version

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326782589&siteId=291194637