CTCaliberTek
Course: Java Developer Path · Lesson 1 of 4Log in to track your progress and earn a certificate when you finish the course.
Programming

Java for Beginners: Install the JDK and Write Your First Program

Published August 26, 2026·Updated October 29, 2026·7 min read
Like SaveLog in to like, save, and track progress.

Introduction

Java programs are compiled to bytecode and run on the Java Virtual Machine, which is why the same program can run on Windows, macOS, and Linux. This tutorial walks you through installing the JDK and compiling and running your first program.

Prerequisites

  • A computer running Windows, macOS, or Linux
  • Access to a terminal or command prompt
  • A plain text editor

Step-by-Step Guide

Step 1: Install a JDK

Download and install a recent long-term support (LTS) release of the JDK, such as 21, from a provider like Eclipse Temurin or Oracle. The JDK includes the compiler (javac) and the tools you need to build programs.

Step 2: Verify the installation

Open a new terminal and check that both the runtime and the compiler are available.

java -version
javac -version

Step 3: Write your first program

Create a file named HelloWorld.java. In Java, a public class must live in a file with the same name as the class.

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

Step 4: Compile and run it

javac compiles the source into bytecode (HelloWorld.class), and java runs it.

javac HelloWorld.java
java HelloWorld

Step 5: Know what each part does

The class is the container for your code. main is the entry point the JVM calls first. System.out.println prints a line to the console. Since Java 11 you can also run a single source file directly with java HelloWorld.java.

FAQs

What is the difference between the JDK and the JRE?
The JDK includes the compiler and development tools. The JRE only runs existing programs. Modern installers ship the JDK, which covers both.
Do I need an IDE to learn Java?
No. The command line is enough to start, but an IDE such as IntelliJ IDEA or VS Code with Java extensions makes larger projects easier.

Summary

With the JDK installed you can compile and run Java from any terminal. From here, learn classes and objects, then collections and exception handling.

Related tutorials

Comments

Log in or create a free account to join the discussion.

  • No comments yet. Be the first to comment.