VSCode Java Run Demo
First time running Java outside a browser? This demo walks you through it — step by step.
Terminal, javac, java, command-line args — from zero to running.
Movie clip is only available in larger viewports.
On some mobile devices, rotating to landscape will allow viewing.
About This Demo — What You’re Watching and Why It Matters
This screen recording shows TechToolsGuru — a co-developer here at TNT and a veteran Java teacher — compiling and running a real Java program (ThreeStoogesDriver.java) directly inside VS Code’s built-in terminal. If you have been using JDoodle or CodeHS to run Java in a browser, this is the next step: running Java on your own machine, the same way working software developers do it every day.
You will see the full workflow: opening a terminal inside VS Code, navigating to the right folder, compiling the source file with javac, and running the compiled program with java — first without command-line arguments (which triggers the defaults), then with three names passed as arguments. You will also see what happens when things go wrong, and how to read the error messages that tell you what to fix.
The written guide below mirrors what the video demonstrates. If a step in the video goes by too fast, use the guide to look up exactly what was typed.
Step-by-Step Guide — Compile & Run Java in VS Code
Before You Start
(1) Java JDK — the Java Development Kit. Download from Adoptium (Temurin) or Oracle. Install it, then restart your computer.
(2) VS Code — code.visualstudio.com
(3) Extension Pack for Java — inside VS Code, press
Ctrl+Shift+X, search “Extension Pack for Java” (by Red Hat), click Install.
Open Your Project Folder in VS Code
Go to File → Open Folder and navigate to the folder that contains your .java file. Click Select Folder. VS Code shows your files in the Explorer panel on the left side.
Open the Built-In Terminal
Press Ctrl + ` (the backtick key — it lives in the top-left corner of your keyboard, above the Tab key). A panel opens at the bottom of the VS Code window. This is a terminal — sometimes called a command prompt, console, or shell. On Windows it opens PowerShell by default.
You can also open it from the menu: View → Terminal.
Navigate to Your .java File’s Folder
The terminal opens in your project’s root folder — but your .java file might be inside a subfolder. You must change directory (cd) to the folder that contains the file before compiling.
# See what folders are here: dir # Move into a subfolder (use Tab to autocomplete folder names): cd ToolTime\StoogesDriverJava\solnResults # Move back up one level: cd .. # See where you currently are: pwd
Tab — the terminal will fill in the rest. This avoids typos and is much faster than typing the full name.
Compile the Program
Type the following command and press Enter. javac is the Java compiler — it reads your human-readable source code and produces a .class file that the computer can execute.
javac ThreeStoogesDriver.java
If the compile succeeds, nothing is printed — silence means success. A new file called ThreeStoogesDriver.class will appear in the same folder. If there are errors, the compiler prints the file name, line number, and a description of the problem.
bin folder to your PATH — ask your teacher or AI assistant for help with the exact steps on your OS.
Run the Program (Without Arguments)
Now run the compiled program. Notice: no .java extension on the java command — you are running the compiled .class file, not the source file.
java ThreeStoogesDriver
Because no names were provided, the program uses its built-in fallback: Moe, Larry, Curly. The interactive loop then starts, waiting for you to type additional names.
Run the Program With Command-Line Arguments
Java programs can accept words typed directly after the class name on the run command. These become the args[] array inside main. Type three names after the class name:
java ThreeStoogesDriver Shemp Joe Curly-Joe
The program reads args[0] = Shemp, args[1] = Joe, args[2] = Curly-Joe and uses those instead of the defaults. This is the same concept as JDoodle’s “Input arguments” field — just typed directly in the terminal.
Common Mistakes to Avoid
java ThreeStoogesDriver.java — Adding .java to the run command tells Java to look for a file named ThreeStoogesDriver.java.class, which doesn’t exist. The compile step (javac) needs the extension; the run step (java) does not.
error: file not found. Always confirm you are in the folder containing the .java file before typing any Java commands.
ThreeStoogesDriver.java in two different subfolders, VS Code’s Java extension may compile the wrong one. The terminal-based workflow avoids this: you navigate precisely to the correct folder and compile exactly that file.
javac / java workflow in the terminal is not affected. You can safely ignore this warning for single-file programs.