Home  >  Article  >  Development Tools  >  Teach you step by step how to set up a Java environment in VSCode

Teach you step by step how to set up a Java environment in VSCode

青灯夜游
青灯夜游forward
2021-11-26 19:14:438177browse

This article will give you a detailed understanding of how to build a Java environment in VSCode. I hope it will be helpful to friends in need!

Teach you step by step how to set up a Java environment in VSCode

1. Software installation

visual studio code download link: https://azure.microsoft.com/zh-cn/products/visual-studio -code/

JDK official website download address: https://www.oracle.com/cn/java/technologies/javase-jdk15-downloads.html

Teach you step by step how to set up a Java environment in VSCode
Specific Which one to choose according to your own computer system:
installer version:
Installer, execute the exe file to install.

binary is the same as archive:
Binary package is a compiled program that can be used directly. After decompression, click the .sh or .bat executable file in the bin directory to use it.

2. Add environment variables

Tips: Add environment variables: Right-click My Computer –> Advanced System Settings –> Environment Variables –> Select User Variables and System variables can be used, double-click path to add the path –> OK

Find the JDK installation path, find the location as shown below
Teach you step by step how to set up a Java environment in VSCode
Add environment variables such as mine :F:\jdk_13.0.2\bin
Teach you step by step how to set up a Java environment in VSCode
In addition, create two more environment variables, the variable names are CLASSPATH and JAVA_HOME respectively, the file paths are slightly different:
CLASSPATH:
Teach you step by step how to set up a Java environment in VSCode
JAVA_HOME:
Teach you step by step how to set up a Java environment in VSCode

##3. vscode configuration

1. Software itself settings

Install the Chinese package: Search Chinese in the software store on the left column and select to install the Chinese package:


Teach you step by step how to set up a Java environment in VSCode Identify the encoding: Click on the settings in the lower left corner, search for Auto Guess Encoding in the search bar, and check the box. The character encoding format can be automatically guessed when reading code to correctly display information such as comments.

Teach you step by step how to set up a Java environment in VSCode
If this is the first time you browse this language, a box will pop up in the lower right corner to prompt you to install an expansion pack to identify the code. Just install it. Of course, you can also go to the app store on the left column. Search and install

2. Compilation environment configuration

Create launch.json:


Teach you step by step how to set up a Java environment in VSCode After creation, you can run it in the code interface:

Teach you step by step how to set up a Java environment in VSCode Or click Run directly:

Teach you step by step how to set up a Java environment in VSCode

Postscript

vscode is more suitable for writing small project code. If it is a large project, you still need to use that one More professional software, such as eclipse. I made a small game at the time, which was a project built using eclipse. It is also easier to find bugs. You can also add libraries, such as jl-1.0.1.jar, and I don’t know how to use vscode. After adding libraries and setting up the project, I often write about bugs that cannot be found. It is more comfortable for me to continue to use vscode to write, and debugging is also more convenient.

Attached is a small game I wrote. Due to the path problem, I can only put it on the desktop and run it and cannot change the folder name. It should be able to be changed in the .classpath file. Let’s see if it can run. It’s fate (^_−)☆.


Teach you step by step how to set up a Java environment in VSCode

Network disk link:

Link: https://pan.baidu.com/s/1cK6brC3dcnTuJ91jlWe9eA
Extraction code: 9x3b

For more knowledge about VSCode, please visit:

vscode tutorial! !

The above is the detailed content of Teach you step by step how to set up a Java environment in VSCode. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete