MacOS system Java development environment configuration

Install and configure Java

First of all, you need to install jdk, and enter the Oracle official website.
Enterprises generally use java8. After entering the page, you can find it by scrolling down.
insert image description here

Choose the macOS system here, and there is only one installation package. Here, new users will be required to register, and the download can only be downloaded after the registration is successful. After the download is complete, double-click, and the installation guide will appear. Click Next until the installation is complete.

Find the terminal in Launchpad->Others, open it and enter java -version, if the java version number can be displayed successfully, it means the installation is successful.

Tips: The mac terminal will be used frequently and can be kept in the dock

At this point, Java is installed, and then configure the environment variables
Enter the following command in the terminal to view the java installation path

/usr/libexec/java_home -V

Look at the last line, the default installation path is /Library/Java/JavaVirtualMachines/jdk version/Contents/Home
Copy this path, then create a configuration file in the terminal, enter the following command

touch ~/.bash_profile

At this point, a blank file will be created, press i to enter the write mode, and write the following content into the configuration file

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk版本/Contents/Home

PATH=$JAVA_HOME/bin:$PATH:.

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

export JAVA_HOME
export PATH

JAVA_HOME is the Java installation path copied in the previous step, press esc after writing, and then enter: wq to save and exit

Tips: The mac terminal uses Linux commands, and friends who are not familiar with it can learn this content first

Enter the following command in the terminal to make the configuration file take effect

source ~/.bash_profile

Continue to enter the following command, if the path just configured is displayed, it means success

echo $JAVA_HOME

Install Intellij Idea

Java development tools, search directly on the Internet, enter Jetbrains official website to download, remember to download the Ultimate version! ! ! This is the enterprise version, which can only be used for free for 30 days. Students can use the email address applied by the school for free. The installation here is very simple, so I won’t say much

Install and configure maven

Maven is a very important package management tool in Java development. It is necessary for development.
First, go to the download page of Maven official website: link
Download zip and decompress it, create a new Environment folder in the root directory, and drag the decompressed maven into it
insert image description here
insert image description here

Open the terminal, enter vim ~/.bash_profile, open the configuration file, and add the following content

export MAVEN_HOME=/Users/xxx/Environment/apache-maven-3.9.3
export PATH=$PATH:$MAVEN_HOME/bin

The version number in the path is determined according to the version you downloaded. Remember to source it after completion to make it take effect.
Enter the following command in the terminal

vim ~/.zshrc

write the following command

source ~/.bash_profile

Then: wq save and exit, source the following .zshrc file

Enter mvn -v in the terminal to display the version number, indicating that the configuration is successful. Here, it should be noted that Java environment variable configuration exceptions will cause maven environment exceptions

After the configuration is complete, we generally modify the configuration in apache-maven-xxx -> conf -> settings.xml, such as replacing it with a domestic Alibaba Cloud image, so that the download speed of dependencies is faster, and then modify the maven settings in Idea
. Change the various paths in the figure below to your own installation path, and then click apply
insert image description here

Install and configure git

Open the terminal, enter git -v, if git is not installed, you will be asked to install XCode at this time, just agree, and then git will be installed
. Execute git -v again, you can see the version of git

First configure the global user name and mailbox, execute in the terminal

git config --global user.name yourname
git config --global user.email youremail

Enter the following command to view all configurations and determine whether the configuration takes effect

git config --list

The configuration just now appears, indicating that it has taken effect

If you want to pull the code from gitlab, you also need to configure the following, you can refer to this blog: link

Guess you like

Origin blog.csdn.net/wzc3614/article/details/131582111