Technology  /  Java

โ˜• Java 15 guides ยท updated 2026

From the JVM to streams, generics, and concurrency โ€” the language behind most enterprise backends, taught with modern Java in mind.

How Java Actually Works: JVM, JDK, Bytecode, and Your First Program

Most Java tutorials start with public static void main and never explain why youโ€™re typing any of it. Then, three months later, youโ€™re staring at an OutOfMemoryError or a ClassNotFoundException with no mental model of whatโ€™s happening under the hood.

This guide takes the opposite approach. Before writing serious Java, itโ€™s worth understanding the machinery that runs it โ€” because that machinery explains almost everything that seems weird about the language at first: the compilation step, the verbose ceremony, and why Java is still the backbone of banking, e-commerce, and Android after nearly three decades.


Why Java Exists

Java was created at Sun Microsystems in the early 1990s by a team led by James Gosling. The original target wasnโ€™t the web at all โ€” it was set-top boxes and consumer electronics. The team needed a language that could run on wildly different chips without being recompiled for each one.

That constraint produced Javaโ€™s defining idea: compile once to an intermediate format, then let a virtual machine translate it for whatever hardware it lands on. Marketing later condensed this into โ€œwrite once, run anywhere,โ€ and while developers joke about โ€œwrite once, debug everywhere,โ€ the core promise held up remarkably well. The same .jar file you build on a MacBook runs unmodified on a Linux server or a Windows box.

When the web exploded in 1995, Java pivoted to it and never looked back. Today it powers a huge share of enterprise backends โ€” payment systems, airline reservations, Netflixโ€™s microservices, most of the big data stack (Hadoop, Kafka, Elasticsearch are all JVM software), and until Kotlinโ€™s rise, virtually all of Android.


The Three Letters You Must Untangle: JDK, JRE, JVM

These acronyms confuse every newcomer, so letโ€™s settle them once.

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ JDK (Java Development Kit) โ”‚
โ”‚ compiler (javac), debugger, jar tool, docs โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ JRE (Java Runtime Environment) โ”‚ โ”‚
โ”‚ โ”‚ core libraries (java.util, java.ioโ€ฆ) โ”‚ โ”‚
โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ JVM (Java Virtual Machine) โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ executes bytecode, manages โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ”‚ memory, JIT compiles hot code โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

If you remember one thing: you write with the JDK, you ship for the JVM.


From Source Code to Running Program

Hereโ€™s the journey your code takes, and itโ€™s genuinely different from both C++ and Python:

Hello.java โ”€โ”€javacโ”€โ”€โ–ถ Hello.class โ”€โ”€JVMโ”€โ”€โ–ถ machine code
(source) (bytecode) (at runtime)
  1. You write Hello.java โ€” human-readable source.
  2. javac compiles it to Hello.class โ€” bytecode, a compact instruction set for an imaginary machine. Not machine code, not source. Think of it as assembly language for a CPU that doesnโ€™t physically exist.
  3. The JVM executes the bytecode. Initially it interprets instructions one at a time. But hereโ€™s the clever part: the JVM watches which methods run frequently (โ€œhot spotsโ€ โ€” this is literally why Oracleโ€™s JVM is called HotSpot), and compiles those to native machine code on the fly using the JIT (Just-In-Time) compiler.

This hybrid model gives Java a property people donโ€™t expect: long-running Java services often run faster than equivalent programs compiled ahead of time, because the JIT optimizes based on how the code actually behaves in production โ€” inlining the methods you really call, optimizing the branches you really take. Itโ€™s also why Java programs feel slow to start: the first few seconds are interpretation and warm-up.

C++ compiles straight to machine code (fast start, no runtime adaptation). Python interprets source directly (no compile step, but much slower execution). Java sits deliberately in between.


Your First Program, Line by Line

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

Save as Hello.java โ€” the filename must match the public class name โ€” then:

Terminal window
javac Hello.java # produces Hello.class
java Hello # runs it

Since Java 11 you can skip the explicit compile for single files (java Hello.java), and since Java 21+ with preview features the ceremony is shrinking further. But you should still understand the classic form, because youโ€™ll see it everywhere:

Every word has a reason. Thatโ€™s very Java: verbose, but rarely mysterious.


What Makes Java Feel Like Java

Static typing, enforced at compile time

int count = 10;
count = "ten"; // compile error โ€” caught before the program ever runs

The compiler rejects entire categories of bugs before execution. In a 500,000-line banking codebase maintained by 40 people, this is not bureaucracy โ€” itโ€™s the reason refactoring is even possible. Modern Java softens the typing ceremony with var (Java 10+): var list = new ArrayList<String>(); โ€” the type is still static, just inferred.

Garbage collection

You allocate objects with new; you never free them. The JVM tracks which objects are still reachable and reclaims the rest automatically. This eliminates the memory-corruption bugs that plague C and C++ โ€” at the cost of occasional GC pauses, which modern collectors (G1, ZGC) have driven down to milliseconds even on huge heaps.

Backward compatibility as religion

Code compiled for Java 8 in 2014 almost always runs on Java 21 today. Enterprises run on Java precisely because upgrading the runtime rarely breaks the application. The flip side: the language evolves cautiously, and old APIs (java.util.Date, anyone?) stay around long after better replacements exist.

An enormous, boring, reliable standard library

Collections, HTTP, file I/O, cryptography, concurrency utilities, date/time โ€” itโ€™s all built in and battle-tested. โ€œBoringโ€ is a compliment in infrastructure.


The Release Cadence: Which Java Should You Learn?

Java historically moved slowly (Java 8 in 2014, Java 9 in 2017 โ€” three years!). Since 2017 it ships a new version every six months, with a Long-Term Support (LTS) release every two years. The LTS versions are what companies actually run:

VersionYearWhy it matters
Java 82014Lambdas, streams โ€” still lingering in legacy systems
Java 112018First LTS of the new era; var, new HTTP client
Java 172021Records, sealed classes, pattern matching basics
Java 212023Virtual threads, sequenced collections, pattern matching for switch
Java 252025Current LTS line

Practical advice: learn on the newest LTS (21 or later), but donโ€™t be shocked when a job throws Java 8 or 11 code at you. The fundamentals in this series apply to all of them; where a feature is modern-only, weโ€™ll flag it.

For installation, most developers use SDKMAN on macOS/Linux (sdk install java 21-tem) or grab an OpenJDK build from Adoptium. Oracleโ€™s JDK and OpenJDK are functionally identical for learning purposes โ€” OpenJDK is the open-source reference implementation.


Where Java Wins (and Where It Doesnโ€™t)

Choose Java when youโ€™re building:

Look elsewhere when:


Common Beginner Confusions, Answered Early

โ€œIs Java slow?โ€ No โ€” that reputation dates to the 1990s interpreters. Modern JIT-compiled Java is within striking distance of C++ for long-running server workloads, and dramatically faster than Python or Ruby.

โ€œIs Java the same as JavaScript?โ€ Not even related. The name was a 1995 marketing decision by Netscape. Java is statically typed and compiled to bytecode; JavaScript is dynamically typed and was born in the browser. Knowing one gives you almost no head start on the other.

โ€œDo I need to understand the JVM to write Java?โ€ To write your first thousand lines, no. To debug production systems, absolutely โ€” memory issues, class-loading problems, and performance tuning all live at the JVM layer. Weโ€™ll go deep on this in the memory management guide.

โ€œWhy is everything a class?โ€ Design philosophy: Java forces structure so that large teams produce navigable code. You may find it ceremonious for a 20-line program. Youโ€™ll appreciate it in a 2-million-line one.


Try It Yourself

Before moving on, do this five-minute exercise โ€” actually type it, donโ€™t just read:

public class Facts {
public static void main(String[] args) {
String name = "Java";
int born = 1995;
int age = 2026 - born;
System.out.println(name + " is " + age + " years old.");
System.out.println("JVM vendor: " + System.getProperty("java.vm.vendor"));
System.out.println("Java version: " + System.getProperty("java.version"));
}
}

Run it. Those System.getProperty calls are your first peek at the JVM introspecting itself โ€” the same mechanism monitoring tools use in production.


A Realistic First-Month Path

People ask โ€œhow long to learn Java?โ€ and the honest answer depends on what โ€œlearnโ€ means. Hereโ€™s a sequencing that has worked for the developers Iโ€™ve mentored, assuming an hour a day:

Week 1 โ€” mechanics. Install a JDK via SDKMAN, install IntelliJ IDEA Community (the de facto standard Java IDE โ€” its autocomplete and error highlighting are effectively a tutor), and get comfortable with the edit-compile-run loop. Work through variables, control flow, and methods by writing tiny programs from scratch โ€” a tip calculator, a temperature converter, FizzBuzz. Typing matters; reading code creates recognition, writing code creates recall.

Week 2 โ€” objects. Classes, constructors, fields, methods. Build something with two or three interacting classes: a library that lends books, a bank with accounts. This is the week the โ€œeverything is a classโ€ ceremony starts making sense.

Week 3 โ€” collections and real programs. ArrayList and HashMap unlock programs that do useful work: word counters, contact books, CSV crunchers. Read stack traces properly this week โ€” every error is a location plus a call path, and learning to read them is the highest-leverage debugging skill that exists.

Week 4 โ€” consolidation. Pick one small project that genuinely interests you and finish it end to end, including handling bad input. Finishing โ€” not starting โ€” is where the learning compounds.

What to deliberately postpone: frameworks (Spring can wait until the language is comfortable), build tools beyond the basics (let the IDE drive Maven/Gradle at first), and concurrency (it deserves respect, and this series covers it when youโ€™re ready).

Frequently Asked Questions

Should I learn Java or Python first? Whichever youโ€™ll stick with. Python has a gentler on-ramp; Java teaches structure and types that transfer everywhere. If your goal is backend engineering jobs specifically, Java (or its ecosystem sibling Kotlin) is directly employable at more large companies.

Is Java free to use? Yes โ€” OpenJDK builds (Adoptium/Temurin, Amazon Corretto, Microsoft) are free for any use, including commercial. Oracleโ€™s own JDK has licensing terms worth reading for production, which is why most teams standardize on an OpenJDK distribution.

What about Kotlin โ€” is Java obsolete? No. Kotlin is a lovely JVM language and dominant on Android, but the JVM ecosystemโ€™s libraries, tooling, and the majority of existing backend code remain Java. Learning Java first makes Kotlin trivial to pick up later; the reverse is also mostly true. The platform knowledge โ€” JVM, GC, collections โ€” transfers completely.

Do I need to memorize the standard library? No โ€” you need to know what exists, not its signatures. The IDE autocompletes; your job is knowing that HashMap is the tool for lookups and that Files.readString exists, not remembering parameter orders.

Whatโ€™s Next

You now have the mental model most tutorials skip: source โ†’ bytecode โ†’ JVM โ†’ JIT-compiled machine code, with the JDK as your toolbox. Everything else in this series builds on it.

Next up: Variables and Data Types, where Javaโ€™s static typing starts paying rent โ€” including the difference between primitives and objects that trips up nearly every newcomer.