Article Directory
Java environment configuration under Windows 10
Update: November 25, 2020
Computer environment:
windows10 64 bit
One, download jdk
First go to the Oracle website to download the jdk installation package corresponding to the operating system.
https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
You can also use the installation package I provided (download date is 2020.11.25 Java SE Development Kit 8 latest version)
Link: https://pan.baidu.com/s/1tL6_u5VDJu7yq2u49NUleg
Extraction code: 97q4
Two, install jdk
-
After the download is complete, click Open all the way and click "Next" to install, the jdk will be installed automatically during the installation process
-
Another window will pop up midway to let you choose the jre installation location, click "Next" to install jre automatically.
That is, the jre installation location is:
C:\Program Files\Java\jdk1.8.0_271
That is, you can open this folder in the folder, which has jre related configuration
- After the installation is complete, you need to configure environment variables
Three, configure environment variables
If you are using the JDK provided by me, and it is installed by default all the way next, then congratulations on your environment variable configuration directly copy and paste mine
Right-click " This Computer " on the desktop , left-click " Properties ", find and click " Advanced System Settings " on the left side of the pop-up window .
Find " Environment Variables " at the bottom right of the pop-up window and click
Set the variable name as follows:
variable name:CLASSPATH
variable:.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar
variable name:JAVA_HOME
variable:C:\Program Files\Java\jdk1.8.0_271
variable name:Path
variable:%JAVA_HOME%\bin
variable:%JAVA_HOME%\jre\bin
The premise of using my environment variables is the default installation, that is, the jre installation location is:
C:\Program Files\Java\jdk1.8.0_271
That is, you can open this folder in the folder, which has jre related configuration
Fourth, verify that the java environment is installed successfully
- Press and hold "
windows+r
" to open the "Run" dialog box, entercmd
, and click "OK" to open the command line. - Enter "
java
","javac
", "java --version
" in order on the command line
No error or no prompt
"
javac,java
" Is not an internal or external command, an executable program or a batch event
Five, run hello world
- Create a new "test" folder in the root directory of Disk D, create a new txt file in the "test" folder, and rename it to "test.java".
- Open "test1.java" with Notepad or NotePad++ and enter the following code
public class test {
public static void main(String[] args) {
System.out.print("Hello World!");
}
}
- Press and hold "ctrl + r" to open the "Run" dialog box, enter cmd, and click "OK" to open the command line.
- Enter "
D:
" - Enter "
cd test
" to enter the "test" folder. - Enter "
javac test.java
" to compile the "test1.java" file into a class file. - Enter "
java test
" to run the newly compiled class file, and you can see the printed "Hello World!"
Microsoft Windows [版本 10.0.18363.1198]
(c) 2019 Microsoft Corporation。保留所有权利。
C:\Users\DeRoy>D:
D:\>cd test
D:\test>javac test.java
D:\test>java test
Hello World!
D:\test>