Create a Class
A Java program needs an entry and a class to host its entry. The filename must match the classname.
- Create Main.java
public class Main {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
- Compile the program
javac Main.java
- Run the file
java Main
- The output should read
Hello World
Getting Started with Java in VS Code
https://code.visualstudio.com/docs/java/java-tutoria
-
Create a Java project using the Java:
Create Java Project
command- Bring up the Command Palette (Ctrl+Shift+P) and then type java to search for this command. After selecting the command, you will be prompted for the location and name of the project. You can also choose your build tool from this command.
-
run and debug Java code
- set a breakpoint, then either press F5 on your keyboard or use the Run > Start Debugging menu item.