What is Java written in?

The Java compiler (javac) is written in Java, making it partially self-hosting. The HotSpot JVM, the primary Java runtime, is written in C and C++. The Java standard library (java.lang, java.util, etc.) is written in Java itself.

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

Details

Java has multiple implementation layers: the compiler, the virtual machine, and the standard library. A complete answer depends on which layer you mean.

The javac compiler is written in Java. It compiles Java source files to JVM bytecode. Because javac is itself written in Java, new versions are bootstrapped using an existing Java toolchain.

The HotSpot JVM, the primary Java runtime, is written mainly in C and C++. HotSpot includes the bytecode interpreter, JIT compiler, garbage collectors, class loader, and native platform integration.

Java implementation layers

LayerWritten inRole
javacJavaCompiles Java source to JVM bytecode
HotSpot JVMC and C++Executes bytecode, JIT-compiles hot code, manages memory
Standard libraryJavaCore APIs such as java.lang and java.util

Explore in the Graph

See implementation and influence relationships interactively.

Open Interactive Graph →

Related Pages