这里要使用 WSL + VSCode
1.在 WSL 中安装 JDK
sudo apt install openjdk-11-jdk
安装完毕后确认 java 版本号
java -version
2.在 VSCode 中启动 Remote-WSL 模式
3.在 Remote-WSL 模式的 VSCode 中安装 Java Extension Pack 插件
4.写一个测试程序 HelloWorld.java
import java.util.Scanner; public class HelloWorld { public static void main(String[] args) { String message; message = "Input your name"; System.out.println(message); Scanner in = new Scanner(System.in); String inputText = in.nextLine(); System.out.println("Hello " + inputText); in.close(); } }
5.编译并运行
编译
javac HelloWorld.java
运行
java HelloWorld
1 Comments (2882 Views)
Leave a Reply