Article Directory
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
jdk
the 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!
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
2. Windows system installation and configuration
2.1 installation
There is not much to explain about the installation, just keep clicking the next step.
The only thing to note is that if you have not modified the installation path, you must remember jdk
the installation location. The installation itself is not difficult, so I won’t say more, 关闭
just click after the installation is complete.
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
For some Win10
and Win11
users, the following operations have the same effect as the above operations
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.
For Win10
and Win 11
users, 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.
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
JAVA_HOME
JDK
bin
2.2.4 Add JAVA_HOME
toPath
In System Variables, find Path
the variable with the variable name , if not, click Create.
In the environment variable editing window of the pop-up window, click 新建
, enter %JAVA_HOME%\bin
, and click Save.
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-x64
the version as an example, click 继续
to enter the password, click to install
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:
3.2.2 Configurationbash_profile
Method 1: GUI operation
In the home directory , open .bash_profile
the file. By default, .bash_profile
the 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 + .
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 终端
)
and enter in the terminal open ~
.
open ~
Method 2: Terminal operation (recommended)
usevi
orvim
editor 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_HOME
variables
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_HOME
The variable containsjdk1.8.0_311.jdk
the 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
PATH
add them after the colon. For example, if I have anotherM2_Home
variable, 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
wq
Enter to confirm save and exit
3.3 Refresh .bash_profile
files
After the configuration is complete, you need to execute source ~/.bash_profile
to 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