Java Introduction
What Java is, why it still runs a huge share of the world's backend systems, and how the JVM, JDK and JRE fit together.
What is Java?
Java is a general-purpose, class-based, object-oriented programming language originally released by Sun Microsystems in 1995 (now owned by Oracle). It was designed around one famous promise: "Write Once, Run Anywhere."
Instead of compiling directly to machine code, Java source code compiles to an intermediate format called bytecode, which runs on the Java Virtual Machine (JVM). Any device with a JVM — Windows, Linux, macOS, a cloud server, an Android phone — can run the exact same .class files.
public class Main {
public static void main(String[] args) {
System.out.println("Hello, Java!");
}
}
Why use Java?
- Portability — bytecode runs identically on any platform with a JVM.
- Huge ecosystem — Maven Central hosts millions of libraries; Spring, Hibernate and countless enterprise tools are built on Java.
- Performance — the JIT (Just-In-Time) compiler translates hot bytecode paths into native machine code at runtime, giving near-native speed.
- Strong typing & tooling — the compiler catches a huge class of bugs before the program ever runs, and IDEs like IntelliJ IDEA give excellent refactoring and autocomplete support.
- Backward compatibility — code written for Java 8 still compiles and runs on Java 21.
- Massive hiring demand — Java still powers the backend of a huge share of banks, airlines, e-commerce platforms and Android apps.
JVM, JDK and JRE
These three acronyms confuse almost every beginner — here's the difference:
| Term | Stands for | What it actually is |
|---|---|---|
| JVM | Java Virtual Machine | The engine that loads, verifies and executes bytecode. It's what makes Java portable. |
| JRE | Java Runtime Environment | The JVM plus the standard class libraries needed to run a Java program. |
| JDK | Java Development Kit | The JRE plus the compiler (javac), debugger, and other tools needed to build a Java program. |
In short: you install the JDK to write and compile Java code. Whoever eventually runs your compiled program only needs a JRE (or just the JVM, bundled into modern JDK distributions).
JDK = JRE + compiler + dev tools
JRE = JVM + standard libraries
JVM = the thing that actually executes your bytecode
How a Java program actually runs
- You write
Main.java(source code). javac Main.javacompiles it toMain.class(bytecode) — this step catches syntax and type errors.java Mainstarts the JVM, which loadsMain.class, verifies the bytecode is safe, and interprets/JIT-compiles it to native instructions.- The JVM also manages memory automatically via the garbage collector, so you never manually
free()an object like you would in C.
Real-world example
Nearly every major bank's core transaction system, most of the backend at companies like LinkedIn and Netflix's middleware, and the entire native Android app ecosystem (via Kotlin/Java interop) run on the JVM. When you tap "Pay" in a banking app, there's a very good chance a Java service processed that request.
Common beginner mistakes
- Confusing
JDK(for developers) withJRE(for running programs only). - Forgetting that the file name must match the public class name (
Main.javamust containpublic class Main). - Assuming Java is interpreted only — in reality the JIT compiler makes long-running Java programs very fast.
Interview questions
Q: Why is Java called "platform independent"? Because Java source compiles to bytecode, not native machine code, and the JVM — not the OS — executes that bytecode. Any OS with a matching JVM can run it unchanged.
Q: Is Java purely interpreted? No. The JVM interprets bytecode initially, then the JIT compiler compiles frequently executed ("hot") code paths into native machine code for speed — a hybrid approach.
Q: What's the difference between JDK and JRE? The JDK includes everything needed to develop Java software (compiler, debugger, tools) plus a JRE. The JRE alone only lets you run already-compiled Java programs.