Free tutorials & notes in Hindi & English · Clean code examples 🧰 Free PDF & Image Tools →
🟢 Foundation  ·  Lesson 03

Java Installation and Setup (JDK)

In this lesson: Download and install JDK, set JAVA_HOME and PATH, compile with javac and run with java — easy steps. Set up now. In Hindi & English.

What you need to install

To write and run Java, you install the JDK (Java Development Kit). It contains the compiler javac (to turn your code into bytecode) and the JVM (to run it). Once the JDK is installed and set up, you can compile and run Java programs from the command line.

💡 JDK = compiler + JVM. Install the JDK, not just the JRE, so you can compile your own code.

Download the JDK

  1. Go to Oracle's Java download page, or get a free build like OpenJDK.
  2. Choose the version for your operating system (Windows, Mac or Linux).
  3. Run the installer and follow the steps.

Any recent long-term-support (LTS) version, like Java 17 or 21, is a good choice for learning.

Setting the PATH

On Windows, after installing, add the JDK's bin folder to the system PATH so the command line can find javac and java.

⚠️ If you skip this, the terminal will say "'javac' is not recognised". On Mac/Linux the installer usually sets this up for you.

Check the version

Open the command line and run both commands:

java -version
javac -version
java version "17.0.1"
javac 17.0.1

If both show a version number, the JDK is installed and your PATH is correct. If javac is not found, revisit the PATH step.

Compile and run a program

Save this as Hello.java:

public class Hello {
    public static void main(String[] args) {
        System.out.println("Hello, Java!");
    }
}

Then in the command line, in that folder:

javac Hello.java   // compile -> makes Hello.class
java Hello         // run (no .class)
Hello, Java!

javac compiles your code to bytecode (Hello.class), and java Hello runs it on the JVM. Note the file name must match the public class name.

Using an IDE

The command line is great for learning, but an IDE makes real work easier:

  • IntelliJ IDEA — very popular, has a free Community edition.
  • Eclipse — long-standing free IDE for Java.
  • VS Code — lightweight, with a Java extension pack.

IDEs add autocomplete, error highlighting and one-click run, so start with one once you are comfortable with the basics.

Common mistakes

  • Installing only the JRE. You need the JDK to compile with javac.
  • Forgetting the PATH. Then javac/java are "not recognised".
  • File name mismatch. The file must match the public class name (Hello.java for class Hello).
  • Adding .class when running. Use java Hello, not java Hello.class.

Summary

  • Install the JDK — it has the compiler and the JVM.
  • Set the PATH so javac and java work anywhere.
  • Check with java -version and javac -version.
  • Compile with javac File.java, run with java File.
  • Use an IDE like IntelliJ or VS Code for real projects.

Next, write your first program in Hello World in Java, or learn the parts in JDK, JRE and JVM.

Frequently Asked Questions

What do I need to install to run Java?
You install the JDK (Java Development Kit). It includes the compiler (javac) to build your code and the JVM/JRE to run it. Download it from Oracle or a free build like OpenJDK.
Why do I need to set the PATH for Java?
Setting the PATH lets you run javac and java from any folder in the command line. Without it, the terminal says "javac is not recognised", because it cannot find the Java tools.
How do I check if Java is installed?
Open the command line and type java -version and javac -version. If both show a version number, the JDK is installed and the PATH is set correctly.
How do I compile and run a Java program?
Compile with javac Hello.java which creates Hello.class (bytecode), then run with java Hello (no .class extension). The two-step compile-then-run is normal for Java.
Do I need an IDE to write Java?
No, you can use any text editor and the command line. But an IDE like IntelliJ IDEA, Eclipse or VS Code makes coding much easier with autocomplete and one-click run, which is helpful as projects grow.
← Back to Java Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

💻 Live Code Editor

This page's programs are ready here — run them, edit them, and learn. No installation needed.
Powered by OneCompiler. The code loads into the editor automatically — press Run to see the output. If the editor does not open, open it in a new tab.
Next topicHello World Program in Java Your progress: 3 / 61 (5%) · Lesson 4 / 61 Continue →

How was this lesson?

Your feedback helps us make the content better.

Write a review or suggestion (optional)

After approval, your name and city may appear publicly with your review. Please do not write your email or phone number.

▶ CodingEasily on YouTube

Learn with video lessons in easy Hindi

Featured video: RDBMS Part 3 – Class XI Commerce IT

▶ Subscribe – it’s free