Java development environment configuration and Vscode construction process

Time:2022-9-18

Java development environment configuration

Before configuring the environment, first use the cmd command to check whether the machine has been configured with a Java environment. The test command is (java or javac or java -version [there is a space between java and -])

cmd测试环境

If the above information appears, it means that the configuration has been completed, and there is no need to repeat the operation! ! ! Otherwise, perform the following operations.

Install JDK in your computer,download link, enter and slide down to display the interface

JDK版本下载

Select the version suitable for you to download, here is the Windows X64 Installer download. Downloading from Oracle's official website involves account registration, you can also visit thislink to download, extraction code: wien

After downloading, click the program to run

JDK下载安装

All operations do not need to be changed, just continue to the next step

安装

Copy the path of the JDK installation. Continue to configure system environment variables.

Right-click this computer -> Properties -> Advanced System Settings -> Environment Variables, enter the following interface

Path1.

Paste the path where the JDK is installed on the computer above (the path can be changed, and the follow-up operations are completed according to the original path here):
Click "New", enter the following as shown (the second line enters the installation path of your computer's JDK)
JAVA_HOME
C:\Program Files\Java\jdk-16.0.1

Path

2. The operation is the same as above, and continue to add the following information:
CLASSPATH
.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar

path

Add the directive in the Path variable

在这里插入图片描述在这里插入图片描述

Click "New" on the right to add these two instructions
%JAVA_HOME%\bin
%JAVA_HOME%\jre\bin

All the way to be determined, and finally enter the cmd window as well, enter the java -version, java, javac commands respectively, the following information is displayed, indicating that the configuration is successful.

在这里插入图片描述在这里插入图片描述在这里插入图片描述

At this point, the Java environment configuration is over.



Configure the Java development environment in Vscode

Vscode is a lightweight source code editor that is well-received for its numerous plugin support. Next, we configure the Java development environment in Vscode.
First find this plugin in the Vscode extension to install

在这里插入图片描述

Java Extension Pack is an extension package that contains some necessary plug-ins for Java development. Generally, basic installation is enough.

在这里插入图片描述

Use the keyboard shortcut Ctrl+Shift+P to open the command panel, enter Configure Java Runtime, and you can see the version of your JDk installed at ②. If you installed Vscode first, you can also click ③ to download the JDK on the pop-up website, and follow the instructions above. text configuration.

在这里插入图片描述

Shortcut Ctrl+, enter settings and click Edit in settings.json
Paste the JDK installation path in javahome (note: when it comes to escape characters, change \ to \ or / )
Tips: The mouse selects a \ shortcut key Ctrl+D, continuous tapping can quickly select all \ , you can change it directly on the keyboard

在这里插入图片描述

After the configuration is complete, write a Java version of HelloWorld for testing.


public class HelloWorld {
	public static void main(String[] args) {
		System.out.println("Hello World!");
	}
}

Click the debug icon on the left to generate the launch.json file

在这里插入图片描述
在这里插入图片描述

Because the plug-in developed by Java has been installed, click Run directly to see the output in the console

在这里插入图片描述

All configurations have been completed, I hope to help everyone!

So far, this article about the configuration of the Java development environment and the Vscode construction process is introduced here. For more information about the configuration of the Java development environment in Vscode, please search for the previous articles of developpaer or continue to browse the related articles below. I hope you will support developpaer more in the future!