Lesson 1.6: Installing Visual Studio Code and Setting Up the Java Development Environment
Introduction
Writing Java programs using a simple text editor is possible, but it is not the most efficient way to develop software. Modern developers use Integrated Development Environments (IDEs) or Code Editors that provide features like syntax highlighting, code completion, debugging, and project management.
In this course, we will use Visual Studio Code (VS Code) because it is free, lightweight, easy to use, and supports Java development through extensions.
By the end of this lesson, your computer will be fully prepared for Java programming.
Learning Objectives
After completing this lesson, you will be able to:
-
Understand what Visual Studio Code is.
-
Download and install Visual Studio Code.
-
Install the Java Extension Pack.
-
Create your first Java project.
-
Run Java programs inside VS Code.
-
Understand the basic VS Code interface.
What is Visual Studio Code?
Visual Studio Code (VS Code) is a free source-code editor developed by Microsoft.
It supports many programming languages including:
-
Java
-
Python
-
C
-
C++
-
JavaScript
-
HTML & CSS
-
PHP
-
C#
VS Code becomes a complete Java development environment after installing the required extensions.
Features of VS Code
-
Free and Open Source
-
Lightweight and Fast
-
Syntax Highlighting
-
Intelligent Code Completion (IntelliSense)
-
Built-in Terminal
-
Debugging Support
-
Extension Marketplace
-
Git Integration
-
Cross Platform (Windows, Linux, macOS)
Step 1: Download Visual Studio Code
Visit the official Visual Studio Code website and download the installer for your operating system.
Choose:
-
Windows
-
Linux
-
macOS
For this course, install the Windows 64-bit version.
Step 2: Install VS Code
Follow these steps:
-
Double-click the downloaded installer.
-
Accept the license agreement.
-
Click Next.
-
Choose the installation location.
-
Keep the default settings.
-
Click Install.
-
Click Finish.
Visual Studio Code is now installed.
Step 3: Launch VS Code
Open Visual Studio Code.
You will see the main interface containing:
-
Activity Bar
-
Explorer
-
Search
-
Source Control
-
Run and Debug
-
Extensions
-
Editor Window
-
Status Bar
Understanding the VS Code Interface
1. Activity Bar
Located on the left side.
It contains icons for:
-
Explorer
-
Search
-
Source Control
-
Run & Debug
-
Extensions
2. Explorer
Displays:
-
Folders
-
Java files
-
Projects
3. Editor Window
The main area where you write Java code.
4. Terminal
The integrated terminal allows you to execute commands without leaving VS Code.
Shortcut:
Ctrl + `
5. Extensions
Extensions add new features to VS Code.
We will install Java support using extensions.
Step 4: Install Java Extension Pack
Open the Extensions tab.
Search for:
Extension Pack for Java
Developed by Microsoft.
Click:
Install
This extension pack includes:
-
Language Support for Java
-
Java Debugger
-
Java Test Runner
-
Maven Support
-
Project Manager for Java
These tools provide everything needed for Java development.
Step 5: Verify Java Installation
The Java Extension Pack automatically checks whether the JDK is installed.
If Java is installed correctly, VS Code will detect it automatically.
If not, install the JDK first before continuing.
Step 6: Create Your First Java Project
Create a folder named:
Core Java Practice
Inside the folder:
Create a new file named:
Hello.java
Step 7: Write Your First Program
Type the following code:
public class Hello { public static void main(String[] args) { System.out.println("Welcome to Core Java!"); } }
Save the file.
Step 8: Run the Program
You can run the program in two ways:
Method 1
Click the Run button at the top of the editor.
Method 2
Open the Terminal and execute:
javac Hello.java
Then:
java Hello
Output:
Welcome to Core Java!
Useful Keyboard Shortcuts
| Shortcut | Function |
|---|---|
| Ctrl + N | New File |
| Ctrl + S | Save File |
| Ctrl + Shift + P | Command Palette |
| Ctrl + ` | Open Terminal |
| Ctrl + / | Comment Code |
| Alt + Shift + F | Format Document |
| F5 | Start Debugging |
Common Problems and Solutions
Problem 1: Java Extension Not Working
Solution:
-
Check whether the JDK is installed.
-
Restart VS Code.
-
Reinstall the Java Extension Pack.
Problem 2: Program Does Not Run
Solution:
-
Save the file.
-
Ensure the file name matches the class name.
-
Check for typing mistakes.
-
Verify that Java is installed correctly.
Problem 3: Terminal Cannot Find Java
Solution:
Verify Java installation using:
java -version
and
javac -version
Best Practices
-
Create a separate folder for Java programs.
-
Save your work frequently.
-
Use meaningful file names.
-
Keep your code properly indented.
-
Practice writing programs daily.
Key Points to Remember
-
VS Code is a free and powerful code editor.
-
Install the Java Extension Pack for Java support.
-
Create one Java file for each program.
-
Always save the file before running it.
-
The class name and file name must be the same.
Lesson Summary
In this lesson, you learned:
-
What Visual Studio Code is.
-
How to install VS Code.
-
How to install the Java Extension Pack.
-
How to create a Java project.
-
How to write and run a Java program inside VS Code.
-
Basic keyboard shortcuts for efficient coding.
Your development environment is now fully ready. In the next lesson, you will write and understand your first Java program line by line.
Practice Questions
-
What is Visual Studio Code?
-
Why do we use the Java Extension Pack?
-
Which shortcut opens the integrated terminal?
-
What is the purpose of the Explorer panel?
-
Why should the file name and class name be the same?
-
How can you run a Java program in VS Code?
Assignment
-
Install Visual Studio Code.
-
Install the Java Extension Pack.
-
Create a folder named Core Java Practice.
-
Create a file named Hello.java.
-
Write and run your first Java program.
-
Take a screenshot of the successful output.