jdk (Windows/Mac with M1/M2 Arm native JDK) installation, with the download links of each version of JDK

Installation suggestions and precautions

  • He let him post, I use Java 8, it is not unreasonable, the version may not be as new as possible, combined with my own environment to consider comprehensively
  • This article will give jdkthe download addresses and installation steps of different systems and versions, and you can directly jump to the corresponding section of the article according to your own needs .
  • This article will give installation suggestions for different systems and scenarios. If you have any other questions, please leave a message at the end of the article.

1. JDK download

1.1 Official Download

Select the corresponding operating system and JDK version, and click the official download link

Windows Mac Linux
Java 8 JDK 8 For Win JDK 8 For Mac JDK 8 For Linux
Java 11 JDK 11 For Win JDK 11 For Mac JDK 11 For Linux
Java 17 JDK 17 For Win JDK 17 For Mac JDK 17 For Linux
Java 18 JDK 18 For Win JDK 18 For Mac JDK 18 For Linux
Java 19 JDK 18 For Win JDK 18 For Mac JDK 18 For Linux

1.2 JDK domestic image

  • Download : https://www.injdk.cn/

  • Features : Almost all supported JDK versions from various channels are included, very convenient, recommended collection!

insert image description here

1.3 Azul JDK ( support ARM native: Apple M1, M2 series )

  • Address : https://www.azul.com/downloads/

  • Features : Complete versions, many compatible system versions, native support for ARM architecture, compatible with Apple M1 and M2 series Macs

insert image description here

2. Windows system installation and configuration

2.1 installation

There is not much to explain about the installation, just keep clicking the next step.
insert image description here
The only thing to note is that if you have not modified the installation path, you must remember jdkthe installation location. The installation itself is not difficult, so I won’t say more, 关闭just click after the installation is complete.

insert image description here

2.2 Configure environment variables

2.2.1 Open system settings

Win + E to open the computer, right-click properties (or right-click the win icon in the lower left corner, click Settings) to enter the system settings menu
insert image description here
For some Win10and Win11users, the following operations have the same effect as the above operations
insert image description here

2.2.2 Open the environment variable setting item

After clicking Properties, select in the pop-up window 环境变量. If the system properties window does not pop up, but the setting interface, refer to the next step.
insert image description here

For Win10and Win 11users, if the system property menu does not pop up directly after clicking Properties, you can directly search in the search box on the upper left of the system settings 环境变量, select directly or press Enter to select 编辑系统环境变量or 编辑账号环境变量both, I choose the former here.
insert image description here

2.2.3 Configure environment variable parameter values

In the pop -up window, click系统变量 New to fill in the variable name , and pay attention to all capital letters. The parameter value fills in the installation path of the installation just now, pay attention to the root directory, not the directory
insert image description here
JAVA_HOME
JDKbin
insert image description here

2.2.4 Add JAVA_HOMEtoPath

In System Variables, find Paththe variable with the variable name , if not, click Create.
insert image description here
In the environment variable editing window of the pop-up window, click 新建, enter %JAVA_HOME%\bin, and click Save.
insert image description here

2.3 Verification

3. Mac system installation guide

See the first part of this article for the jdk download method, but go into details, just choose the appropriate version.

3.1 Installation

Download the dmg file, here I take jdk-8u341-macosx-x64the version as an example, click 继续
insert image description here
to enter the password, click to install
insert image description here

3.2 Configure environment variables

3.2.1 First confirm the installation path of JDK

By default, the JDK installation path is:

/Library/Java/JavaVirtualMachines/

The blogger installed 3 versions of jdk here, as shown in the figure:
insert image description here

3.2.2 Configurationbash_profile

Method 1: GUI operation

In the home directory , open .bash_profilethe file. By default, .bash_profilethe file is hidden. You can use shift + command + .the shortcut key to switch 打开/关闭to display the hidden file. Note that there is a ! in the shortcut key .. If it is a black apple system, use it. shift + win + .
insert image description here
If you don’t know 家目录which one or where it is, just open the terminal directly (you can use the shortcut key command + 空格, then enter 终端)
insert image description here
and enter in the terminal open ~.

open ~

Method 2: Terminal operation (recommended)
useviorvimeditor to directly open the file, entervim ~/.bash_profile

vim ~/.bash_profile

If the permissions are insufficient, you can add sudo to execute and enter the password.

sudo vim ~/.bash_profile

3.2.3 Configuration JAVA_HOMEvariables

Once opened .bash_profile, add the following at the end of the file (or anywhere):

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_311.jdk/Contents/Home
PATH=$JAVA_HOME/bin/:.
CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
export JAVA_HOME
export PATH
export CLASSPATH

Notice:

  • JAVA_HOMEThe variable contains jdk1.8.0_311.jdkthe directory name of your JDK, just replace it with the directory name installed on your computer.

  • Note PATH=$JAVA_HOME/bin/:.that there is a.

  • If you have other variables, you can PATHadd them after the colon. For example, if I have another M2_Homevariable, you can configure it as follows:

    JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_311.jdk/Contents/Home
    PATH=$JAVA_HOME/bin/:$M2_Home/bin/:$PATH:.
    CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
    export JAVA_HOME
    export PATH
    export CLASSPATH
    export M2_Home=/Users/wulei/Services/apache-maven-3.6.3
    
  • If it is not included in the directory .bash_profile, just create a new file!

3.2.4 Save configuration

After modification, save the file, the steps are as follows:

  • Switch to input method to English input state
  • Press ESC to enter bottom line mode (command mode)
  • Enter wqEnter to confirm save and exit

3.3 Refresh .bash_profilefiles

After the configuration is complete, you need to execute source ~/.bash_profileto make it take effect

source ~/.bash_profile

3.4 Verification

Open the terminal, enter java -version, when the java version number is output, it means that the environment variable has been configured successfully
insert image description here

Guess you like

Origin blog.csdn.net/wlei0618/article/details/126861940