The JVM (Java Virtual Machine) is the runtime engine that executes bytecode — it alone can't compile anything. The JRE (Java Runtime Environment) bundles a JVM plus the standard library classes needed to run compiled Java programs, but has no compiler. The JDK (Java Development Kit) bundles everything in the JRE plus javac and other development tools — it's what you actually need to write and compile Java, and modern JDK distributions (since Java 11) include the JRE's functionality directly rather than shipping it separately.
Installing a JDK
Several vendors distribute OpenJDK builds — Eclipse Temurin, Amazon Corretto, and Oracle's own JDK are common choices, all built from the same open-source OpenJDK project and functionally near-identical for everyday development.
$ java -version
openjdk version "25" 2025-09-16
$ javac -version
javac 25Compiling and running by hand
For learning, compiling and running directly with javac/java is worth understanding before reaching for a build tool — the public class name must exactly match the filename.
$ javac Main.java // compiles Main.java into Main.class
$ java Main // runs the compiled class (no .class extension)Real projects use Maven or Gradle
Beyond a single-file example, real Java projects almost always use a build tool to manage dependencies, compilation, testing, and packaging together — Maven (XML-configured, older, still very common) and Gradle (Groovy/Kotlin-configured, newer, generally faster) are the two dominant choices, covered in their own dedicated topic.