Courses / Complete Java Course by codesofrohan / Introduction / Install JDK & VS Code

Install JDK & VS Code

Before we start writing Java programs, we need to set up our development environment. This involves installing two essential tools:

  • Java Development Kit (JDK) – Required to write, compile, and run Java programs.

  • Visual Studio Code (VS Code) – A lightweight and powerful code editor where we will write our Java code.

Once these tools are installed and configured correctly, you'll be ready to build Java applications throughout this course.


Why Do We Need to Install Java?

Java is not like a regular application that you simply double-click and use.

When you write Java code, your computer needs special tools to:

  • Understand Java syntax.

  • Compile Java code into Bytecode.

  • Run Java applications.

  • Detect programming errors.

These tools are provided by the Java Development Kit (JDK).

Without the JDK, you cannot develop Java applications.


Why Do We Need VS Code?

Technically, you can write Java code in Notepad.

However, writing programs in Notepad becomes difficult as projects grow.

VS Code provides many useful features such as:

  • Syntax Highlighting

  • Auto Completion (IntelliSense)

  • Error Detection

  • Integrated Terminal

  • Code Formatting

  • Debugging Support

  • Extensions for Java Development

These features make coding faster, easier, and less error-prone.


Real-World Example

Imagine you're learning to draw.

You could draw on plain paper using a pencil.

But professional artists use drawing tablets, brushes, rulers, and advanced software because these tools make their work easier and more efficient.

Similarly:

  • JDK is like your drawing materials—it gives you the ability to create.

  • VS Code is like your digital art studio—it provides a comfortable workspace with powerful tools.

Together, they make Java development smooth and enjoyable.


Step 1: Download the Java Development Kit (JDK)

The first step is to download the latest Long-Term Support (LTS) version of the JDK.

At the time of recording this course, you can download the latest LTS version available.

Choose the installer that matches your operating system.

For Windows users:

  • Windows x64 Installer (.exe)

After downloading, double-click the installer to begin the installation process.


Step 2: Install the JDK

The installation process is straightforward.

  1. Launch the installer.

  2. Click Next.

  3. Choose the installation location (the default location is recommended).

  4. Click Install.

  5. Wait for the installation to complete.

  6. Click Finish.

Congratulations! The JDK is now installed on your computer.


Step 3: Verify the Java Installation

After installing Java, it's a good practice to verify that everything is working correctly.

Open Command Prompt and type:

java --version

If Java is installed correctly, you will see output similar to:

java version "21"
Java(TM) SE Runtime Environment
Java HotSpot(TM) 64-Bit Server VM

Now check the Java compiler:

javac --version

Expected output:

javac 21

If both commands display version information, your Java installation is successful.


What If the Command Is Not Recognized?

Sometimes, Windows may display:

'java' is not recognized as an internal or external command.

This usually means the PATH Environment Variable is not configured correctly.

The PATH variable tells Windows where Java is installed.

Most modern JDK installers configure the PATH automatically. If not, you can add the JDK's bin folder to the system PATH manually.

Example:

C:\Program Files\Java\jdk-21\bin

After updating the PATH, restart the Command Prompt and try the commands again.


Step 4: Download Visual Studio Code

Now let's install our code editor.

Download the latest version of Visual Studio Code (VS Code) for your operating system.

The installer is small and installs within a few minutes.


Step 5: Install VS Code

Run the installer and follow these steps:

  1. Accept the license agreement.

  2. Choose the installation folder.

  3. Keep the default settings.

  4. Enable "Add to PATH" (recommended).

  5. Enable "Open with Code" (optional but useful).

  6. Click Install.

  7. Launch VS Code.

VS Code is now ready to use.


Step 6: Install the Java Extension Pack

By default, VS Code does not understand Java.

We need to install the Extension Pack for Java.

To do this:

  1. Open VS Code.

  2. Click the Extensions icon on the left sidebar.

  3. Search for:

Extension Pack for Java
  1. Click Install.

This extension pack includes several useful tools, such as:

  • Java Language Support

  • Debugger for Java

  • Maven Support

  • Java Test Runner

  • Project Manager for Java

These extensions provide everything needed for Java development.


Step 7: Verify the Development Environment

Once the JDK and Java Extension Pack are installed, your development environment is ready.

To ensure everything is configured correctly:

  • Open VS Code.

  • Verify that no Java-related extension errors are displayed.

  • Open the integrated terminal.

  • Run the following commands:

java --version

and

javac --version

If both commands return the installed Java version without any errors, your system is ready for Java development.

In the next lesson, we'll create our first Java program and understand every line of code in detail.


Common Mistakes Beginners Make

While installing Java, beginners often encounter a few common issues:

  • Installing only the JRE instead of the JDK.

  • Forgetting to install the Java Extension Pack in VS Code.

  • Incorrect PATH environment variable configuration.

  • Restarting neither VS Code nor Command Prompt after installation.

  • Downloading a JDK version that doesn't match the system architecture (32-bit vs. 64-bit).

Checking these points usually resolves most installation-related problems.


Key Points to Remember

  • Install the Java Development Kit (JDK) to develop Java applications.

  • Verify the installation using java --version and javac --version.

  • Install Visual Studio Code as your code editor.

  • Install the Extension Pack for Java to enable Java development features.

  • Configure the PATH environment variable if required.

  • Ensure your development environment is working before writing your first Java program.


Conclusion

Setting up your Java development environment is the first practical step toward becoming a Java programmer. By installing the JDK, configuring your system correctly, and using Visual Studio Code with the Java Extension Pack, you now have everything needed to begin your Java journey. In the next lesson, we'll write our first Java program and understand every line of code, building on the environment you've successfully configured today.

🔖 Bookmark saved successfully!