Java Introduction
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
BankAccountor aStudent. You will learn this from the Classes, Objects & static lesson onwards. - Statically typed: every variable has a fixed type, such as
intfor whole numbers orStringfor 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.
- You write source code in a file ending in
.java. - 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. - 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.
public class Greeting {
public static void main(String[] args) {
int runs = 48;
System.out.println("Rohan scored " + runs);
}
}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:
javac Greeting.java
javap -c GreetingThis is the part of the javap output for the main method:
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: returnYou 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.
| Name | Full form | What it is | Who needs it |
|---|---|---|---|
| JVM | Java Virtual Machine | The engine that runs bytecode | Built into every Java installation |
| JRE | Java Runtime Environment | The JVM plus the standard class library | People who only run Java programs |
| JDK | Java Development Kit | The JRE plus tools: javac, java, javap, jshell, jar and more | Programmers (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.
javac -versionJava 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.
| Version | Released | Type |
|---|---|---|
| Java 8 | March 2014 | LTS (still found in old projects) |
| Java 11 | September 2018 | LTS |
| Java 17 | September 2021 | LTS |
| Java 21 | September 2023 | LTS |
| Java 25 | 16 September 2025 | LTS, current |
| Java 26 | 17 March 2026 | Feature release |
| Java 27 | 15 September 2026 | Feature 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.
javaccompiles.javasource files into.classbytecode; 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:
- What is the difference between a
.javafile and a.classfile? - Your friend Meera wants to write Java programs. Should she install a JRE or a JDK? Why?
- 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
- A
.javafile holds human-readable source code. A.classfile holds bytecode produced byjavac, which the JVM runs. - A JDK, because it includes the compiler
javacand other tools, plus the runtime needed to run programs. - 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?
javac compiles source code into bytecode, which any JVM can run.
2. Which one should a programmer install to write and compile Java?
The JDK includes the compiler and tools, plus the runtime.
3. Which Java version is the current long-term support (LTS) release in this course?
Java 25 (September 2025) is the current LTS; Java 27 is newer but not LTS.
4. Why can the same .class file run on Windows and Linux?
Bytecode is platform-neutral; each operating system has its own JVM.
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
