Table of Contents
Install VS Code for Java to enjoy a fast, lightweight, and customizable coding environment without the heavy load of traditional IDEs. With the right extensions, Visual Studio Code becomes a powerful Java development setup that’s perfect for beginners and professionals alike.
In this guide, we’ll cover:
- Installing VS Code
- Setting up Java and necessary extensions
- Creating and running your first Java program
- Tips for Java development in VS Code
1. Why Use VS Code for Java?
Visual Studio Code (VS Code) is a free, open-source code editor developed by Microsoft. While it’s not a full IDE like Eclipse or IntelliJ IDEA, it can be customized to act like one using extensions.
Advantages of VS Code for Java:
- Lightweight & Fast – Loads quicker than full IDEs.
- Customizable – Supports thousands of extensions.
- Beginner-Friendly – Easy setup for learning Java.
- Cross-Platform – Works on Windows, macOS, and Linux.
2. Installing VS Code
Step 1 – Download VS Code
- Visit the official site: https://code.visualstudio.com/
- Click Download for your operating system.
- Wait for the file to download.

Step 2 – Install VS Code
- Run the installer.
- Accept the license agreement.
- Keep the default location or choose your own.
- Check Add to PATH and Create Desktop Icon options.
- Click Install and finish the setup.
3. Install Java JDK
Before running Java programs in VS Code, you need to install the Java Development Kit (JDK).
- Go to Adoptium Temurin JDK or Oracle JDK Download.
- Download the latest LTS version ( Java 21).

- Install it using the wizard.
- Verify Installation:
java -version
You should see something like:
java version "21.0.1"
4. Install VS Code Extensions for Java
- Open VS Code.
- Click the Extensions icon on the left sidebar (
Ctrl+Shift+X
). - Search for Extension Pack for Java.
- Click Install.

This will install:
- Language Support for Java™ by Red Hat
- Debugger for Java
- Java Test Runner
- Maven for Java
- Java Dependency Viewer
5. Creating Your First Java Program in VS Code
Option 1 – Quick Java File
If you just want to try Java quickly:
- Create a folder named
JavaPrograms
. - Open it in VS Code (
File → Open Folder
). - Create a new file
HelloWorld.java
. - Add:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, VS Code!");
}
}
- Save (
Ctrl+S
). - Open the terminal (`Ctrl+“) and run:
javac HelloWorld.java
java HelloWorld
Option 2 – Java Project Using VS Code’s Built-in Tools
For a proper structure:
- Press
Ctrl+Shift+P
→ type:
Java: Create Java Project
- Select No Build Tools (for beginners) or Maven/Gradle (for advanced users).
- Choose your project folder and name it (e.g.,
MyJavaProject
). - VS Code creates:
MyJavaProject
├── src
│ └── App.java
└── .vscode
- Open
App.java
and write:
public class App {
public static void main(String[] args) {
System.out.println("My first Java program in VS Code!");
}
}
- Click Run ▶ at the top right or press
Ctrl+F5
.
6. Running Java in VS Code
You can run programs by:
- Clicking Run ▶ above the
main
method. - Using the terminal:
javac FileName.java
java FileName
- Using Run and Debug (left sidebar).
7. Tips for Java Development in VS Code
- Enable IntelliSense: Auto-complete for faster coding.
- Organize Classes: Use the Java Dependency Viewer.
- Auto Save: Turn on in
File → Auto Save
. - Install Maven: For managing dependencies in big projects.
8. Troubleshooting
Issue: "java" not recognized
Fix: Ensure JDK is installed and PATH is set.
Issue: Run button missing
Fix: Install Extension Pack for Java and reload VS Code.
Conclusion
Now you know how to install VS Code for Java, set up extensions, and run your first program. This lightweight setup is great for both students and developers who want a flexible coding environment.
With just JDK + VS Code + Java Extension Pack, you can start coding Java in minutes. Give it a try and enjoy a faster, simpler development experience.
Resources
You May Also Like
- Java Introduction to Programming: My Exciting Day 1 Journey from Zero to Beginner
My personal first-day experience learning Java — from setting up the environment to writing my very first program. - Java Learning Roadmap 2025 – From Zero to Hero
A step-by-step guide to how I plan to learn Java in 2025, perfect for beginners like me. - Aptitude Tricks for Beginners – Easy Mental Math Techniques
Quick tricks for multiplication, LCM, squaring, and cubes — useful for placement and coding exams. - Types of Nouns in English Grammar – Simple Explanation with Examples
Learn all types of nouns clearly with examples — great for communication skills and competitive exams. - Data Cleaning with Titanic Dataset – A Beginner’s Guide
Learn the complete, beginner-friendly process of cleaning and preparing the Titanic dataset for machine learning, with practical examples and tips. - History Of Java Programming Language