This article has participated in the "Newcomer Creation Ceremony" event to start the road of gold creation together.
foreword
Java program development is inseparable from tools , because good tools can allow us to focus more on development itself
- For example: IDE , Eclipse
Tools have the advantages of tools, it can even avoid the selection and configuration of JDK during our project development
However , in some cases, we still need to control the Java command or environment locally , for example: Setting up Ali cache technology under Windows : jetCache requires JDK8 version
So how to freely switch the local IDE version? Let's find out together.
Do I have to go to the official website to install the JDK?
I don't think it is necessary, why do you say that? Unless we are working on individual projects, when the Jar package has strict requirements for the JDK version, we need to download it from the official website at this time.
During normal development, we can download the corresponding JDK through the IDE tool , and the tool automatically configures the environment.
In order to take care of all the students who are beginners in Java who have trouble with the environment configuration, here are two ways to configure and install JDK.
Installing Window JDK on the official website takes 18 as an example
download
In fact, you can still find the download through the connection point above , download the Installer version
More versions can be found in the picture below:
Install
Confirm the installation location
Now installing JDK will give you configuration environment variables by default
at this address:
C:\Program Files\Common Files\Oracle\Java\javapath
We need to delete this environment in the system path variable or move to the bottom
Configure environment variables
New JAVA18_HOME
system variable
Select the directory where the JDK is installed
Create a new JAVA_HOME
system variable, the variable value is%JAVA18_HOME%
means by
JAVA_HOME
pointing toJDK18这个目录
Add environment variables to Path
enter:%JAVA_HOME%\bin
IDE tool to download JDK
Click on Project Structure
Click the plus sign to download
Select the corresponding version and download location
version switch
Just replace JAVA_HOME
the value inside, the actual version name is mainly named by yourself
Summarize
The configuration of the original environment
graph TD
JAVA_Home --> path
Multi-environment management configuration now
erDiagram
Java8_Home }|--o{ Java_Home : use
Java_Home ||--|{ path : get
Java18_Home }|..o{ Java_Home : unuse
By setting the form of variables, changing the value of JAVA_Home can realize the switching of JDK versions
test
use:java -version
Go try your JDK multi-environment configuration!