What is Java written in?
What Java is used for
Java is a workhorse of enterprise back-end systems, Android apps, and big-data tooling. Its "write once, run anywhere" JVM, strong tooling, and vast ecosystem (Spring, Hibernate) make it a staple of banks, large web services, and Android development.
Notable software: Android apps, Minecraft (Java Edition), and big-data systems like Apache Hadoop, Kafka, and Elasticsearch.
About Java
Java is an object-oriented programming language. It is a statically typed and garbage-collected language that compiles to bytecode that runs on a virtual machine. It supports object-oriented and imperative programming. Compiling to bytecode for a virtual machine is the same model the JVM and .NET use: the VM, not the CPU, interprets or JIT-compiles the bytecode.
Java first appeared in 1995 and was designed by James Gosling and Sun Microsystems at Sun Microsystems. Today Java is one of the most widely used programming languages in the world.
Java in the language family tree
Java drew on ideas from C++, Simula, Ada, Smalltalk, and Mesa and went on to influence Kotlin, Scala, Groovy, C#, D, and JavaScript.
Sources: Wikipedia · Wikidata · Official site
Quick Facts
- Compiler
- javac is written in Java
- Runtime
- HotSpot JVM is written in C and C++
- Standard library
- Mostly Java
- Compiled output
- JVM bytecode
Java compiler vs JVM runtime
Java has a two-stage execution model that separates compilation from running. The javac compiler takes Java source files and produces class files containing JVM bytecode. Bytecode is a compact, platform-independent instruction set: the same class files run on Windows, Linux, and macOS without recompilation. Javac itself is written in Java and is part of the JDK (Java Development Kit). Because javac is a Java program, building a new version of javac requires an existing Java compiler.
Executing bytecode is a different job from compiling source. The HotSpot JVM, which is the production JVM in OpenJDK (and thus in Oracle JDK, Amazon Corretto, Eclipse Temurin, and others), is written primarily in C and C++. HotSpot includes an interpreter for cold code paths, a JIT compiler that compiles hot methods to native machine code, and a suite of garbage collectors. The JIT compiler observes which methods are called most often and optimizes those aggressively, including inlining call chains that would be expensive to analyze at compile time.
The Java standard library (java.lang, java.util, java.io, java.nio, and friends) is largely written in Java, though some classes have native methods that delegate to C or C++ for low-level OS integration. The combination gives Java its portability: application code and most of the standard library are bytecode that the JVM runs anywhere; only the JVM itself is platform-native code.
HotSpot JVM and modern JIT compilation
HotSpot's name comes from its original insight: most programs spend most of their time in a small fraction of their code. HotSpot monitors execution counts and compiles hot methods to native code using two JIT compilers: C1 (the client compiler, fast to compile but less optimized output) and C2 (the server compiler, slower to compile but generates heavily optimized native code). By default, methods start with the C1 tier and are promoted to C2 if they remain hot enough.
GraalVM is a JDK distribution that replaces the C2 compiler with Graal, a JIT written entirely in Java. Graal can apply more aggressive speculative optimizations because it can use the full Java type system to represent its internal analysis. GraalVM also offers Native Image, which AOT-compiles Java applications to self-contained native executables by running compilation offline, reducing startup time and memory footprint significantly.
Modern Java garbage collector options include: G1 (Garbage First, the default since Java 9, designed for large heaps with predictable pause targets), ZGC (concurrent, sub-millisecond pauses, available since Java 15, generational since Java 21), and Shenandoah (concurrent compaction, contributed by Red Hat). Each collector makes different tradeoffs between throughput, latency, and footprint.
Java implementation layers
| Layer | Written in | What it does |
|---|---|---|
| javac | Java | Compiles Java source to JVM bytecode (.class files) |
| HotSpot JVM (interpreter + JIT) | C and C++ | Executes bytecode; JIT-compiles hot methods to native code via C1 and C2 |
| Graal JIT | Java | Alternative JIT in GraalVM; replaces C2 with a Java-written optimizing compiler |
| Java standard library (java.*) | Java (with native stubs) | Core APIs; some native methods delegate to C for OS calls |
| GC (G1, ZGC, Shenandoah) | C++ | Memory management, running concurrently with application threads |
Java release history
Java was created by James Gosling and colleagues at Sun Microsystems beginning in 1991, under the internal codename "Oak." The Green Project aimed to build a language for consumer electronics with a small footprint and platform independence. When the consumer electronics market did not materialize, the team pivoted to the web: Java 1.0 launched in January 1996 alongside the promise of "Write Once, Run Anywhere," backed by the first browser-embedded JVM.
Java 1.1 (1997) added inner classes, reflection, and JDBC. Java 1.2 (1998, branded Java 2) introduced the Collections framework and the Swing UI toolkit. Java 5 (2004, previously numbered 1.5) was the biggest language update before Java 8: generics, annotations, enum types, autoboxing, and the enhanced for loop. Java 8 (March 2014) added lambda expressions, the Stream API, and the new java.time package.
Oracle acquired Sun in 2010. Java 9 (September 2017) introduced the module system (Project Jigsaw) and shifted to a six-month release cadence. Since then, Java releases arrive in March and September, with Long-Term Support (LTS) versions every three years. LTS releases: Java 11 (September 2018), Java 17 (September 2021), Java 21 (September 2023). Pattern matching, sealed classes, records, and virtual threads (Project Loom) shipped across Java 14 through 21.
Frequently Asked Questions
Evidence Sources
- https://en.wikipedia.org/wiki/Java_(programming_language)
- https://openjdk.org/groups/compiler/
- https://kotlinlang.org/docs/faq.html
- https://github.com/JetBrains/kotlin
- https://en.wikipedia.org/wiki/Scala_(programming_language)
- https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java
- https://en.wikipedia.org/wiki/Apache_Groovy
- https://github.com/apache/groovy
- https://en.wikipedia.org/wiki/C_Sharp_(programming_language)
- https://dlang.org/overview.html
- https://en.wikipedia.org/wiki/JavaScript
- https://en.wikipedia.org/wiki/Dart_(programming_language)
- https://en.wikipedia.org/wiki/Kotlin_(programming_language)
- https://en.wikipedia.org/wiki/PHP
- https://en.wikipedia.org/wiki/Vala_(programming_language)
- https://en.wikipedia.org/wiki/Mesa_(programming_language)
- https://en.wikipedia.org/wiki/Haxe
- https://en.wikipedia.org/wiki/GraalVM
- Java on Wikidata (Q251)