🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
💼 Servicesℹ️ About✉️ ContactView Pricing Plansfrom $10

How to Install Java and JDK — Setup Hello World on Windows

Java BasicsJava Installation and Setup🟢 Free Lesson

How to Install Java and JDK — Setup Hello World on Windows

Learning Objectives

  • Download and install a Java Development Kit on Windows
  • Explain the difference between the JDK, the JRE, and the JVM
  • Configure the system PATH so command line tools work from any folder
  • Compile and run a Hello World program from the terminal

Overview

To write and run Java programs you need the Java Development Kit, usually called the JDK. The JDK contains the compiler named javac, the launcher named java, documentation tools, and core libraries. Older versions separated a smaller Java Runtime Environment for running programs only, but modern JDK installers include everything you need as a student.

This lesson targets Windows 10 and Windows 11. The ideas transfer easily to macOS and Linux: you install a JDK, you set the PATH variable, then you compile and run. The only differences are menu names and shell syntax.

Step 1: Download a JDK

Open your browser and visit the download page for a trusted JDK vendor such as Oracle, Microsoft, Amazon Corretto, or Eclipse Temurin. Choose the Windows installer, the 64-bit build, and an LTS release such as 21 or 25. LTS stands for long-term support, meaning the vendor ships security patches for years.

Run the installer and accept the defaults. The default installation folder is usually under Program Files on the C drive. Make a note of that folder because you will point the PATH variable at its bin subfolder.

Step 2: Set the PATH Variable

The PATH is an environment variable. An environment variable is a named value that the operating system shares with every program you start. When you type a command in the terminal, Windows searches each folder listed in PATH for a matching executable.

  1. Press the Windows key, type environment variables, and choose Edit the system environment variables.
  2. Click the Environment Variables button.
  3. Under System variables, select Path, then click Edit.
  4. Click New and add the full path to your JDK bin folder, for example C:\Program Files\Eclipse Adoptium\jdk-21\bin.
  5. Click OK on every dialog to save.

Open a brand new terminal window. Old windows do not reload environment variables. Type the verification commands below. You should see version numbers instead of a not recognized error.

java -version
javac -version

Step 3: Create Your Project Folder

Decide where your practice files will live. Create a simple folder such as C:\java-projects. Inside it, create a file named HelloWorld.java using Notepad, VS Code, or IntelliJ IDEA Community Edition. The file name must match the class name exactly, including capital letters, because Java rules require it.

Type the following program carefully. Java is case sensitive, so HelloWorld and helloworld are different names.

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

Step 4: Compile and Run

From the terminal, change into your project folder and run the two commands below. The compiler reads your source file and produces a file named HelloWorld.class. That file holds bytecode for the JVM.

cd C:\java-projects
javac HelloWorld.java
java HelloWorld

If everything is set up correctly, the terminal prints Hello, World! on its own line. You have now written, compiled, and executed a real Java program.

Common Setup Problems

ProblemLikely causeFix
Command not recognizedPATH missing or terminal not restartedRecheck the bin folder entry and open a new terminal
Class not foundWrong folder or wrong class nameConfirm the file name matches the class and you are in the right directory
Invalid flag or version mismatchMultiple JDKs installedRun java -version and clean up old PATH entries
File saved as HelloWorld.java.txtFile extensions hidden in ExplorerEnable file name extensions and rename the file

Key Takeaways

💡

  • The JDK gives you the compiler, the launcher, and the standard libraries
  • PATH tells Windows which folders to search when you type a command
  • javac turns source code into bytecode, and java runs that bytecode
  • File names and class names must match, letter for letter
  • Always open a new terminal after changing environment variables

Practice Questions

  1. What is the difference between compiling a program and running a program in Java?
  2. Why must the file HelloWorld.java contain a class named HelloWorld?
  3. Your terminal says java is not recognized. List two checks you would perform.

Extended Learning: Beyond the Basics

Key Concepts Summary

This lesson covers fundamental concepts that serve as building blocks for more advanced topics. Master these basics before moving to intermediate and advanced material.

Prerequisite Knowledge

Before studying this topic in depth, ensure you understand:

  • Basic definitions and terminology
  • Core formulas and their derivations
  • Common applications in real-world scenarios
  • Typical pitfalls and misconceptions

Step-by-Step Walkthrough

Let us work through a complete example to solidify understanding:

Step 1: Identify the problem type. Determine which category this problem falls into and which approach is most appropriate.

Step 2: Apply the relevant formula. Substitute known values into the appropriate equation, paying attention to units and constraints.

Step 3: Simplify and solve. Work through the algebra step by step, checking each intermediate result.

Step 4: Verify the answer. Check that the solution satisfies the original conditions and makes logical sense.

Common Mistakes to Avoid

  1. Misidentifying the problem type — Always start by categorizing the problem
  2. Incorrect formula application — Verify the formula applies to your specific case
  3. Unit errors — Always check units are consistent throughout
  4. Sign errors — Pay careful attention to positive and negative values
  5. Rounding too early — Keep full precision until the final answer
  6. Forgetting constraints — Check that solutions satisfy all given conditions

Real-World Applications

Understanding this concept is essential for:

  • Advanced problem solving in examinations
  • Building intuition for more complex topics
  • Developing analytical thinking skills
  • Applying mathematical reasoning to practical situations

Practice Exercises

  1. Basic: Solve 5 problems of increasing difficulty using the core concept.
  2. Intermediate: Apply the concept to word problems with multiple steps.
  3. Advanced: Combine this concept with 2-3 other topics in a comprehensive problem.
  4. Challenge: Create your own problem that requires this concept plus additional knowledge.

Interview and Exam Tips

  • Common question patterns: Identify which exam or interview formats test this topic
  • Time management: Practice completing problems within time constraints
  • Common traps: Know the typical mistakes examiners set as distractors
  • Verification strategy: Develop a quick method to check your answer

Related Topics

Quick Reference Card

ConceptFormula/RuleKey InsightCommon Use
Core DefinitionSee main textUnderstand the intuitionFoundation for all applications
Key FormulaSee main textMemorize the derivationDirect problem solving
Special CaseSee main textRecognize when it appliesSimplifies complex problems
Edge CaseSee main textKnow the limitationsAvoids errors

Further Reading

For students who want to go deeper:

  • Standard textbooks on the subject
  • Research papers applying this concept
  • Online courses with video explanations
  • Practice problem collections with detailed solutions
CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-11-14

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Need Expert Java Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement