Java Installation and Development Environment

Before you can write and run Java programs, you need to prepare your computer. Think of it like setting up a kitchen before you start cooking. You first need the right tools, and then you can start making food.

In this tutorial, you will learn how to install Java, what each tool does, and how to prepare your computer for writing Java programs.


What You Need Before Writing Java Programs

To create Java programs, you need two things:

  • Java Development Kit (JDK)
  • A code editor or an IDE

The JDK allows your computer to understand, compile, and run Java programs.

The code editor or IDE is where you write your Java code.


What is the JDK?

JDK stands for Java Development Kit.

It is the complete package required to develop Java applications.

Imagine you are building a house.

  • The bricks are your Java code.
  • The workers are the tools inside the JDK.
  • The finished house is your working Java program.

Without the JDK, your computer cannot turn your Java code into a working program.


What Does the JDK Contain?

The JDK contains several tools.

The two most important ones are:

javac

This is the Java compiler.

It converts your Java source code into bytecode.

For example:

You write

HelloWorld.java

The compiler converts it into

HelloWorld.class

The .class file is what the Java Virtual Machine (JVM) understands.


java

This command runs your Java program.

Example:

java HelloWorld

This tells the JVM to execute your compiled program.


JDK, JRE and JVM

These three names often confuse beginners.

Let’s understand them using a simple example.

Imagine you buy a DVD movie.

  • The movie is your Java program.
  • The DVD player is the JRE.
  • The motor inside the DVD player is the JVM.
  • The movie studio that creates DVDs is the JDK.

Now let’s understand each one.


JVM (Java Virtual Machine)

The JVM is responsible for running Java programs.

It reads the bytecode (.class files) and executes it.

Without the JVM, a Java program cannot run.


JRE (Java Runtime Environment)

The JRE contains:

  • JVM
  • Supporting files and libraries needed to run Java programs

The JRE allows users to run Java applications.

It does not contain tools for writing or compiling Java programs.


JDK (Java Development Kit)

The JDK contains everything.

It includes:

  • JRE
  • JVM
  • Java compiler
  • Development tools

If you want to become a Java programmer, install the JDK.

You do not need to install the JRE separately because it is already included in the JDK.


Difference Between JDK, JRE and JVM

JDKJREJVM
Used to develop Java programsUsed to run Java programsExecutes Java bytecode
Contains compilerDoes not contain compilerDoes not compile code
Includes JREIncludes JVMSmallest part
Installed by developersUsed by end usersWorks behind the scenes

Downloading the JDK

You can download the latest JDK from Oracle’s official website or other trusted Java distributions.

Popular choices include:

  • Oracle JDK
  • OpenJDK
  • Eclipse Temurin

For learning Java, any of these will work.


Installing the JDK

The installation process is similar to installing any normal software.

Steps:

  1. Download the installer.
  2. Double-click the installer.
  3. Keep clicking Next.
  4. Finish the installation.

The JDK is now installed on your computer.


What is the PATH Environment Variable?

After installing Java, your computer should know where Java is located.

This is done using the PATH environment variable.

Think of PATH as your computer’s contact list.

Suppose your friend asks,

“Where is Rahul’s house?”

If the address is saved in your phone, you can find it immediately.

Similarly, PATH stores the location of important programs.

When you type

java

your computer checks the PATH to find where Java is installed.

Without PATH, the computer may say:

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

How to Set the PATH Variable

The exact steps depend on your operating system.

In general:

  1. Find the bin folder inside the JDK installation.

Example:

C:\Program Files\Java\jdk-21\bin
  1. Copy this path.
  2. Open the Environment Variables settings.
  3. Edit the PATH variable.
  4. Add the copied path.
  5. Save the changes.
  6. Restart Command Prompt or Terminal.

Now your computer knows where Java is installed.


Verifying the Installation

After installation, open:

  • Command Prompt (Windows)
  • Terminal (Linux/macOS)

Type:

java -version

If Java is installed correctly, you will see something like:

java version "21"

Now check the compiler.

Type:

javac -version

Example output:

javac 21

If both commands work, your Java installation is successful.


Choosing a Code Editor or IDE

You need a place to write your Java code.

There are two common options.

Code Editor

A code editor is lightweight and mainly used for writing code.

Examples:

  • Visual Studio Code
  • Notepad++
  • Sublime Text

A code editor gives you basic features like syntax highlighting and file editing.


IDE (Integrated Development Environment)

An IDE is a complete software package for programming.

It provides many extra features such as:

  • Code suggestions
  • Error detection
  • Debugging tools
  • Project management
  • Automatic code formatting

Popular Java IDEs include:

  • IntelliJ IDEA
  • Eclipse
  • Apache NetBeans

Which One Should You Choose?

If you are just starting to learn Java, an IDE can make learning easier because it helps you spot mistakes and provides useful suggestions.

Many beginners choose IntelliJ IDEA Community Edition because it is free and offers an excellent experience for Java development.

As you become more comfortable with Java, you can also practice using a simple code editor and the command line. This helps you understand how Java programs are compiled and run behind the scenes.


Your Java Development Environment is Ready

Once you have:

  • Installed the JDK
  • Verified the installation using java -version and javac -version
  • Set the PATH correctly (if required)
  • Installed a code editor or IDE

your Java development environment is ready.

You can now start writing, compiling, and running your first Java program.


Summary

  • Java programs are developed using the JDK.
  • The JDK includes the JRE, JVM, compiler, and other development tools.
  • The JVM executes Java bytecode.
  • The JRE provides everything needed to run Java programs.
  • The JDK is used to develop Java applications.
  • The PATH environment variable helps your computer find Java commands.
  • Use java -version and javac -version to verify the installation.
  • You can write Java programs using a code editor or an IDE such as IntelliJ IDEA, Eclipse, or Apache NetBeans.
  • Once the JDK and an editor or IDE are installed, your Java development environment is ready for programming.

Similar Posts

  • Introduction to Java

    What is Java? Java is a programming language that is used to build software. Think of it like this: When we write Java code, we are giving instructions to the computer. The computer reads those instructions and performs the required task. For example, you can use Java to create: Why was Java created? Before Java,…