Back to Movie Clips

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

You need three things installed:
(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.
Step 1

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.

Why “Open Folder” and not “Open File”? Opening a folder gives VS Code the context to find all your Java files and compile them correctly. Opening a single file is like reading one page of a book without knowing which chapter it’s in.
Step 2

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.

What is a terminal? Before smartphones and graphical interfaces, every computer was controlled by typing commands as text. The terminal is that text interface. It’s still how most professional developers run their programs because it’s faster and more powerful than clicking buttons.
Step 3

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 autocomplete is your best friend. Type the first few letters of a folder name and press Tab — the terminal will fill in the rest. This avoids typos and is much faster than typing the full name.
Step 4

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.

Error: “javac is not recognized” — The JDK was not added to your system PATH during installation. Try restarting VS Code and your computer first. If still broken, you need to add the JDK bin folder to your PATH — ask your teacher or AI assistant for help with the exact steps on your OS.
Step 5

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.

Step 6

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

Wrong: 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.
Wrong folder — If you try to compile or run from the wrong directory, you will get error: file not found. Always confirm you are in the folder containing the .java file before typing any Java commands.
Two files with the same class name — If your project has a 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.
The “package does not match” warning in VS Code — VS Code’s Java extension may flag your file with a red circle in the Problems panel, saying the declared package does not match the expected package. This is a VS Code IDE analysis warning, not a compile error. Your javac / java workflow in the terminal is not affected. You can safely ignore this warning for single-file programs.
The program shown in this demo is the Three Stooges Driver — TNT Tool Time Entry #6.  Visit the entry page to copy the code and take on the five-stage vibe-coding adventure →