Mac computer m1 build java development environment reference manual

1 Background introduction

Developers often change computers, or replace them with new ones, which means rebuilding the development environment is very troublesome. But the new computer is in hand, and it is not good not to change it. This article is dedicated to recording the steps of setting up the java development environment on the mac computer m1. Hope to be helpful to readers, one-stop service.
When there is time in the later period, there will be an article about the win10 environment, and the mac environment is currently introduced.

2 JDK installation

M1 version MacBook installs Arm version of JDK:
https://cdn.azul.com/zulu/bin/zulu8.60.0.21-ca-jdk8.0.322-macosx_aarch64.dmg
Official website address:
https://www.azul.com/downloads/?version=java-8-lts&os=macos&package=jdk#zulu
insert image description here
Different machines need to choose the corresponding version . Mine is m1, choose arm64

demo@admin54 ~ % java -version
openjdk version "1.8.0_345"
OpenJDK Runtime Environment (Zulu 8.64.0.19-CA-macos-aarch64) (build 1.8.0_345-b01)
OpenJDK 64-Bit Server VM (Zulu 8.64.0.19-CA-macos-aarch64) (build 25.345-b01, mixed mode)

After installation, enter: java -version
to view the corresponding JDK version.

3 Maven installation

There are many maven versions,
download them here. You can choose a new version: https://maven.apache.org/download.cgi

4 Git installation

There are many ways to install,
1 you can use the command line to install:

git clone https://github.com/git/git

2 Then check the specific version:

git --version
git version 2.32.1 (Apple Git-133)

3 Generate SSH key
After the installation command is executed, enter the command to confirm the installation is complete: cd ~/.ssh ;ls

demo@admin54 ~ % cd ~/.ssh ;ls
config		id_rsa		id_rsa.pub	known_hosts

Enter: cat id_rsa.pub to view the content information of the public key (backup)

4 You need to go to github or gitee to configure later.

5 Configure environment variables

Open the terminal, configure the environment variables of JDK and Maven
1, vim ~/.bash_profile
2, modify the configuration file, and replace the path with your own installation path

export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
​
export M2_HOME=/Users/demo/soft/apache-maven
export PATH=$PATH:$M2_HOME/bin

3. After modification, activate the command:
source ~/.bash_profile

6 Install IntelliJ IDEA

You need to be careful here. The version of the idea selected by different versions is different. If you choose the wrong version, you will find that the idea will be particularly stuck when running. For example, if you use an m1 chip and use an intel idea, if you open 2 to 4 project projects, or run the springboot project locally, it will be particularly stuck.

If you use the m1 chip and use the corresponding idea version, the idea will be very smooth, and you will not get stuck after opening 10 projects. It will be OK after 1 minute of local startup, no need to wait 5 minutes, 10 minutes. The following is the author's own configuration:

insert image description here
The important thing is said three times.
When downloading here, you must download the same chip as your computer, otherwise it will be stuck!
When downloading here, be sure to download the same chip as your own computer, otherwise it will be stuck!
When downloading here, be sure to download the same chip as your own computer, otherwise it will be stuck!

Configure JDK

1. Add JDK configuration
Open: file -> project structure
insert image description here

2. Set the project JDK version

insert image description here

7 memory optimization

Display memory indicator
This function is very useful. Right-click on the bottom right of the idea and select memory indicator-memory indicator to display the memory status.
insert image description here

insert image description here
If you find that the computer is stuck, and the memory usage is displayed to be relatively slow, you can click it to kill some internal parts, and the idea will not be so stuck.

8 Plug-in related

You can see the author's other blog. It introduces a lot of plug-ins that are more practical for development.
https://blog.csdn.net/qq_39463175/article/details/129478435?spm=1001.2014.3001.5501

Guess you like

Origin blog.csdn.net/qq_39463175/article/details/131154299