How to write Java in vscode: First download VSCode and install and run it; then click the extension icon on the left side of the interface to install the JDK and configure environment variables; then install the Java extension and open a Java code file; finally right-click the editing window , and select "Run Code".
In many cases, I just want to write a very simple Java program with only a few lines of code and see the results. Although Visual Studio / Eclipse / IntelliJ IDEA is powerful, it is too heavy and feels like overkill when used.
Recommended course: Java Tutorial.
Now there is an additional option, which is to use Visual Studio Code (VS Code), a powerful text editor launched by Microsoft. You can take a look at the effect first:
First of all, there must be some prerequisites
Download VS Code and install it, run VS Code, click on the on the left Extension
icon,
Then search for and install the following extension:
Steps required to run Java code
Install the latest version of JDK and JRE (download page)
Configure Java system path parameters (refer to this article for the method, where the JDK installation path should be set according to the actual installation path)
After the installation is complete, enter java -version
and javac -version
in the command prompt or PowerShell. If the correct Java version number is displayed, it means that the previous The configuration is already correct.
Search and install the following extensions in VS Code
Open a Java code file, right-click the editing window, and select Run Code
, the program running results will be displayed in the Terminal
window.
When writing a program using a new file, you need to click the Plain Text
button in the lower right corner or press Ctrl K
→M
), select the language as Java.
Now you can write Java programs in it.
The above is the detailed content of How to write java in VS Code. For more information, please follow other related articles on the PHP Chinese website!