Running VSCode with Java
Note that for using Java we DO NOT USE a docker environment. You will run all your programs locally on your machine.
-
Determine which version of the Java Developers Kit (JDK) is currently installed on your machine. Open a terminal/powershell/command-prompt (not in VScode) and check your Java version
java -version
-
If your version of Java is less than 11. Install the latest version of Java. (The latest version is 17, but you only need at least version 11)
Oracal also provides a handy installation guide, if you run into issues.
-
Install the Extension Pack for Java plugin for VS Code
-
In VSCode create a new folder, or open an existing folder.
- Create a new file called Hello.java and populate the file with the hello world code.
/*Hello.java*/ public class Hello { public static void main(String args[]){ System.out.println("hello, world"); } }
-
Open a new terminal in vscode.
- In the terminal window use javac to compile Hello.java, then use java to run Hello.