Java Introduction

Java · Lesson 1 of 32 7 min read Updated

Java is one of the most widely used programming languages in the world. Bank servers, railway and airline booking systems, large shopping sites, Android apps and tools like Apache Kafka all run Java code. When you learn Java, you learn a language that companies have trusted for nearly thirty years and still hire for every day.

In this lesson you will learn what Java is, how a Java program actually runs on your computer, what the words JDK, JRE and JVM mean, and which version of Java you should learn in 2026.

What is Java?

Java is a general-purpose, object-oriented, statically typed programming language. Each of those words has a simple meaning:

  • General-purpose: you can build almost anything with it: web servers, desktop tools, Android apps, games and data pipelines.
  • Object-oriented: you organise code into classes and objects that model real things, such as a BankAccount or a Student. You will learn this from the Classes, Objects & static lesson onwards.
  • Statically typed: every variable has a fixed type, such as int for whole numbers or String for text, and the compiler checks the types before the program runs. Many mistakes are caught early, before your users ever see them.

Java was created by James Gosling and his team at Sun Microsystems and first released in 1996. Oracle bought Sun in 2010 and leads Java's development today, together with many other companies, in an open-source project called OpenJDK.

How a Java program runs

Most languages either compile code straight to machine code (like C) or read it line by line while running (like Python). Java does something in between, in two steps.

  1. You write source code in a file ending in .java.
  2. The Java compiler, javac, checks it and turns it into bytecode, stored in a file ending in .class. Bytecode is a compact set of instructions for an imaginary computer.
  3. The Java Virtual Machine (JVM) loads the bytecode and runs it. While it runs, the JVM's JIT compiler (just-in-time compiler) turns the busiest parts of your program into real machine code, so long-running Java programs become very fast.

Here is a tiny program. Do not worry about every word yet; you will write it yourself in Your First Java Program.

Java
public class Greeting {
    public static void main(String[] args) {
        int runs = 48;
        System.out.println("Rohan scored " + runs);
    }
}
Output
Rohan scored 48

After compiling, you can look inside Greeting.class with the javap tool that comes with Java. The commands below compile the file, then print the bytecode instructions:

Terminal
javac Greeting.java
javap -c Greeting

This is the part of the javap output for the main method:

Output
public static void main(java.lang.String[]);
  Code:
     0: bipush        48
     2: istore_1
     3: getstatic     #7                  // Field java/lang/System.out:Ljava/io/PrintStream;
     6: iload_1
     7: invokedynamic #13,  0             // InvokeDynamic #0:makeConcatWithConstants:(I)Ljava/lang/String;
    12: invokevirtual #17                 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
    15: return

You never need to write bytecode, but seeing it once explains Java's famous promise: "write once, run anywhere". The same .class file runs on Windows, Linux and macOS, because each system has its own JVM that understands the same bytecode.

JDK, JRE and JVM

These three names confuse almost every beginner. They fit inside each other like boxes.

NameFull formWhat it isWho needs it
JVMJava Virtual MachineThe engine that runs bytecodeBuilt into every Java installation
JREJava Runtime EnvironmentThe JVM plus the standard class libraryPeople who only run Java programs
JDKJava Development KitThe JRE plus tools: javac, java, javap, jshell, jar and moreProgrammers (you)

As a learner, you always install a JDK. It contains everything else. To check whether a JDK is already on your computer, open a terminal and ask for the compiler's version; if the command is not found, you will install one in the next lesson.

Terminal
javac -version

Java versions and LTS releases

Since Java 10 in 2018, a new Java version comes out every six months, in March and September. Most versions are supported for only six months. Every two years one version is marked LTS (Long-Term Support), and vendors provide security updates for it for many years. Companies usually run LTS versions in production.

VersionReleasedType
Java 8March 2014LTS (still found in old projects)
Java 11September 2018LTS
Java 17September 2021LTS
Java 21September 2023LTS
Java 2516 September 2025LTS, current
Java 2617 March 2026Feature release
Java 2715 September 2026Feature release, newest

This course teaches Java 25 LTS, the version you should learn and use today. Java 27 is newer, but it is not an LTS release, and its new language features are still in preview (experimental and switched off by default), so it adds little for a learner.

Many college labs and older projects still use Java 17 or 21. That is fine: almost everything in this course works there too. Features that need Java 22 or later are always shown in a box marked as a newer feature, so you know exactly which parts need a recent JDK.

Where Java is used

  • Backend web services: frameworks such as Spring Boot power the server side of many banking, insurance and e-commerce systems.
  • Android: Android apps can be written in Java, although Google now recommends Kotlin, a language that also runs on the JVM.
  • Big data and messaging: Apache Kafka, Hadoop and Elasticsearch are written in Java or run on the JVM.
  • Tools and games: IntelliJ IDEA and Minecraft: Java Edition are Java programs.

Common mistakes

  • Installing only a JRE. Without the JDK you have no javac, so you cannot compile. Install a JDK.
  • Thinking Java is slow because it uses a virtual machine. The JIT compiler turns hot code into machine code, so Java is fast enough for stock exchanges and payment systems.
  • Learning from a Java 8 tutorial. Modern Java has var, records, text blocks, switch expressions and virtual threads. Old tutorials miss all of these.
  • Mixing up Java and JavaScript. They share four letters, not a language.

Key points

  • Java is a general-purpose, object-oriented, statically typed language that runs on the JVM.
  • javac compiles .java source files into .class bytecode; the JVM runs the bytecode and JIT-compiles hot code.
  • The JDK contains the JRE, which contains the JVM. Programmers install the JDK.
  • A new Java version arrives every six months; LTS versions arrive every two years.
  • Java 25 is the current LTS and the version this course teaches; Java 27 is the newest release.

Exercise

Answer these in your own words, in a notebook or a text file:

  1. What is the difference between a .java file and a .class file?
  2. Your friend Meera wants to write Java programs. Should she install a JRE or a JDK? Why?
  3. A company runs its payment server on Java 21. Is that an LTS version? Which newer LTS should it plan to move to?
Show solution
  1. A .java file holds human-readable source code. A .class file holds bytecode produced by javac, which the JVM runs.
  2. A JDK, because it includes the compiler javac and other tools, plus the runtime needed to run programs.
  3. Yes, Java 21 is an LTS release (September 2023). The next LTS is Java 25 (September 2025), so the company should plan to upgrade to Java 25.

Quick Quiz

1. What does the javac command produce?

2. Which one should a programmer install to write and compile Java?

3. Which Java version is the current long-term support (LTS) release in this course?

4. Why can the same .class file run on Windows and Linux?

Learn Java with a mentor

Free lessons get you started. Our Java, C & C++ Programming training adds real projects and code reviews from working developers.

  • Project-based learning
  • Mentor code reviews
  • Free counselling call