Before learning, let’s configure the development environment
Development tool selection
-
Eclipse (or IntelliJ IDEA)
-
JDK (version ≥ 1.8)
Installing the development environment
1. The JDK installation
1.1 find choose to download the latest version in’s official website: www.oracle.com/java/techno…
After downloading, follow the steps to install
After installed, the default path to the JDK: / Library/Java/JavaVirtualMachines/JDK – 15.0.2. JDK
1.2. Then open iTerm to configure environment variables
Type the command to edit.bash_profile directly
vim ~/.bash_profile
Copy the code
The following interface appears. Enter E to enter editing mode
Then enter I on the screen and run the following command
Finally, press Esc and enter :wq to save and exit the editing
Type Java -version to verify that the installation was successful
2. Install development tools
Here we choose IntelliJ IDEA by default to install.
Follow the steps to install it
Configuring Basic Settings
1. Font Settings
Select Preferences in the title bar
Then search for font in the search box and find the corresponding position to change the font and size
2. Code enhancement tips
Or findPreferences
And then search forcode completion
Find the corresponding option to uncheck and check
3. Modify the workspace code
Once again, go to Preferences and search enCOD to find the corresponding option to change to UTF-8, which supports Chinese encoding display
Create a project
1. After the basic configuration is complete, let’s create the first project
2. Then select Java, add the JDK you downloaded in the Project SDK, and click Next
3. Select Create Project from Template to generate the template project and click Next
4. Enter the project name and the package information, then click Finish
5. We write down the code to print Hello world in the main. Java file, and then click the triangle to run the program