How to Set up a Java Development Environment under Mac OS and configure Java environment variables, osjava
1. Open the terminal and search in the finder (This MAC) to find the Terminal 2. In cdlouiedeAir :~ Cdlouie $ (cdlouie is my computer user name) and enter sudo vim/etc/profile 3. enter the user name and password of the computer after the password. The password is not displayed. then, press the I key editor status ("/etc/profile" [readonly] 16L, 369C) at any location to switch to INSERT (-- INSERT -- W10: Warning: Changing a readonly file) after you move the cursor to the last line of fi, press enter to wrap the line and insert the following code: # Here is the JAVA environment variable 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 to exit the editing status. 6. Press shift + colon, a colon will appear in the editor, and then enter wq! Press enter to save. 7. Check and enter sudo vim/etc/profile again to check whether the inserted code is successfully saved. 8. Note: The jdk version of the inserted code can be queried using the terminal command: java-version.