AlgoInsight

Free lesson · Java Basic To Advance

What is Java

Easy8 min readjava

Interactive animation: One word, three things - the Java language, the JVM that runs bytecode, and the platform of library plus tooling.

Defining the Thing

Brandon's opening Topic answered "why Java?" This Topic answers the prerequisite question: "what is Java, mechanically?" The two questions sound similar but they're different. The first is about value. The second is about the actual technical thing — what gets installed when you install Java, what runs when you run Java code, what's actually happening under the hood.

Hi, I'm Olena Marchenko. I'm Head of Product at Microsoft, working primarily on the Azure developer tools team. I came to programming late — I didn't study computer science. I learned to code at 26 from freeCodeCamp and YouTube tutorials while transitioning out of a 4-year career as a financial analyst in Warsaw. That background means I know what it feels like to learn something like Java without a CS foundation, and I know which parts trip up self-taught developers most.

I'll be your primary voice for most of Module 1, plus Modules 2-6 (the syntax foundations), Modules 12 (build tools and packaging) and 25 (modern Java features). Brandon takes over for the OO modules. Nikhil and Emeka handle concurrency and memory. Arun co-authors every Interview Lens. The course is multi-voiced, with each of us writing where we have genuine expertise.

Java Is Three Things, Not One

When most people say "Java," they're conflating three distinct things:

  1. The Java programming language — the syntax, keywords, type system, and rules you write code against
  2. The JVM (Java Virtual Machine) — the runtime that executes Java programs
  3. The Java platform — the standard library plus tooling that ships with Java installations

These three are related but separable. Other languages can target the JVM without using Java syntax (Kotlin, Scala, Clojure, Groovy all do this). Other JVMs exist beyond Oracle's official one (OpenJDK, Eclipse Temurin, Amazon Corretto, GraalVM). The platform itself evolves through Java Community Process specifications independently of any single vendor.

This separation matters because interview questions probe each piece differently. "What's the difference between JDK, JRE, and JVM?" is asking whether you understand the platform structure. "Does Java run on the JVM?" is conflating the language with the runtime. Knowing which is which signals depth.

graph TD
    A[Java the Language<br/>Syntax, types, OO model] -->|compiled to| B[Bytecode<br/>.class files]
    B -->|executed on| C[JVM<br/>Virtual Machine runtime]
    C -->|provides| D[Java Platform<br/>Standard library + tooling]

    E[Other JVM Languages<br/>Kotlin, Scala, Clojure] -->|also compile to| B
    F[Multiple JVM Vendors<br/>OpenJDK, Temurin, Corretto] -->|implement| C

    style A fill:#7c3aed,color:#fff
    style B fill:#10b981,color:#fff
    style C fill:#3b82f6,color:#fff
    style D fill:#f59e0b,color:#fff
This diagram shows the three layers of "Java." At the top, the Java programming language defines syntax, types, and the OO model. Java source code compiles down to bytecode, stored in .class files. That bytecode is executed by the JVM — the Java Virtual Machine runtime. The JVM provides access to the Java platform, which is the standard library plus tooling. Importantly, the JVM also runs bytecode from other languages — Kotlin, Scala, Clojure all compile to JVM bytecode. And multiple vendors implement their own JVMs that all conform to the JVM specification.

Java the Language

The Java programming language is defined by the Java Language Specification (JLS) — a formal document that describes exactly what valid Java code looks like and what it means. The current version is the JLS for Java 21 (with Java 25 specifications recently published).

Key characteristics:

Statically typed. Every variable has a type declared (or inferred via var). Types are checked at compile time. Type errors are caught before the program runs.

Object-oriented. Almost everything in Java is an object, organized into classes with inheritance and polymorphism. There are primitives (int, boolean, etc.) for performance, but the language is designed around objects.

Class-based. Code is organized into classes. There are no standalone functions at the top level (unlike Python or JavaScript). Even the main method lives inside a class.

Compiled. Source code is compiled before it runs. The compilation step catches errors that interpreted languages catch only at runtime.

Garbage collected. Memory management is automatic. You don't free objects explicitly — the JVM's garbage collector reclaims them when they're no longer referenced.

Multi-paradigm. While primarily object-oriented, modern Java supports functional programming through lambda expressions, streams, and method references. The language has grown more flexible over time.

The JVM

The Java Virtual Machine is what actually runs Java programs. It's a software-implemented "virtual machine" that pretends to be a CPU, with its own instruction set (Java bytecode) and execution model.

When you run a Java program, here's what happens:

  1. You type java MyProgram (or click run in your IDE)
  2. The JVM process starts up
  3. The JVM loads MyProgram.class (the bytecode file)
  4. The JVM verifies the bytecode for safety
  5. The JVM begins executing bytecode in its interpreter
  6. As code runs frequently ("hot paths"), the JVM's JIT (Just-In-Time) compiler converts it to native machine code for speed
  7. Throughout execution, the garbage collector runs in the background reclaiming unused memory
  8. When the main method returns (or System.exit() is called), the JVM exits

This indirection — bytecode running on a virtual machine rather than native code running directly on hardware — has costs and benefits. The cost is some performance overhead and JVM startup time. The benefits are portability (the same bytecode runs anywhere), safety (the bytecode verifier catches certain bugs before execution), and dynamic optimization (the JIT can optimize based on runtime behavior in ways an ahead-of-time compiler can't).

Modern JVMs (HotSpot is the most common) are extraordinarily sophisticated. They include multiple JIT compilers, several garbage collector algorithms to choose from, profiling and observability tools, and support for native interop. Understanding the JVM at a high level is essential for senior Java engineering.

graph LR
    A[java command] --> B[JVM starts]
    B --> C[Load .class file]
    C --> D[Verify bytecode]
    D --> E[Interpreter runs bytecode]
    E -->|hot paths detected| F[JIT compiles to native]
    F -->|fast native code| E
    G[Garbage Collector] -.->|reclaims memory in background| E

    style B fill:#7c3aed,color:#fff
    style E fill:#10b981,color:#fff
    style F fill:#3b82f6,color:#fff
    style G fill:#f59e0b,color:#fff
This diagram shows what happens when you run a Java program. The java command starts the JVM process. The JVM loads the compiled .class file containing bytecode. Before execution, the bytecode is verified for safety — invalid bytecode is rejected. The interpreter begins running the bytecode. As certain methods or loops are called frequently (becoming "hot paths"), the JIT compiler kicks in and converts those hot paths to native machine code. Future executions use the optimized native code directly. Throughout all this, the garbage collector runs in the background reclaiming memory from objects that are no longer reachable.

Interactive animation: The cost of a virtual machine - overhead and startup time, against portability, bytecode verification and runtime JIT optimization.

The Java Platform

The Java platform is the standard library plus tooling. When you install a JDK, you get:

Core libraries organized into packages:

Tools:

This standard library is unusually comprehensive. You can build production applications using only the standard library and never installing a third-party dependency. In practice you'll use frameworks and libraries (Spring, Jackson, etc.) but the foundation is solid.

Interactive animation: Three commands that prove an installation - java --version, javac --version, and jshell printing Hello at its prompt.

JDK Distributions

Multiple vendors distribute JDKs. They all implement the same Java specification — code that runs on one runs on all — but they differ in licensing, support, and bundled tools.

Common distributions:

For learning and most professional work, Eclipse Temurin or Amazon Corretto are the safe defaults. They're free, well-maintained, and produce identical behavior to Oracle JDK for almost all purposes.

Versions and LTS

Java has shifted to a 6-month release cadence. A new Java version comes out every March and September. Most of these "feature releases" get 6 months of support and then are superseded by the next.

Every few years, a release is designated LTS (Long Term Support) and receives extended support — typically 8+ years. LTS versions are what enterprises use in production.

Recent LTS versions:

For interview prep and new projects, Java 21 or Java 25 are the right targets. Java 17 if your target employer is still on it. Java 8 only if explicitly required — it lacks many modern features that interviews now probe.

Common Pitfalls

Warning: Confusing the language, runtime, and platform. "Java" can mean any of three things depending on context. Interview answers that conflate them signal shallow understanding. Be precise.

Assuming all JVMs behave identically. They mostly do, but some advanced features (GraalVM's AOT compilation, Azul's pauseless GC) are vendor-specific. For interviews, you can assume HotSpot (the JVM in most distributions) unless otherwise specified.

Picking a JDK distribution randomly. Different distributions have different support timelines, performance characteristics, and licensing. For production work, vetting the distribution matters. For learning, Temurin or Corretto are safe defaults.

Targeting Java 8 in 2026. Java 8 was released in 2014 and lacks features (modules, records, sealed classes, pattern matching, virtual threads) that modern interviews probe. Unless an employer specifically uses Java 8, target Java 21 or newer for interview prep.

Why This Matters in Interviews

Interview: Senior Java interviews routinely open with version and platform questions. "What's the difference between JDK, JRE, and JVM?" (covered in Topic 1.5). "What Java version are you most comfortable with?" "What changed between Java 8 and Java 17?" Candidates who can speak fluently about Java versions and the platform structure signal currency. Candidates who can't signal that they learned Java once and stopped paying attention.

Topic 26.12 has the full senior-candidate answers for these questions.

Try It

Exercise: Verify your Java installation and understand what's installed:

  1. Run java --version — note the version number and JVM name
  2. Run javac --version — confirm the compiler is installed (this is what makes it a JDK rather than just a JRE)
  3. Run jshell — opens Java's REPL. Type System.out.println("Hello") and press Enter. Type /exit to quit.
  4. Find your JDK installation directory (often /usr/lib/jvm/... on Linux or C:\Program Files\Java\... on Windows) and look at the directory structure. Notice the bin/ directory containing tools and lib/ containing libraries.

Understanding where Java lives on your machine pays off when you have version conflicts or need to debug installation issues later.

Back to Java Basic To Advance