Java Architecture C++ Language Architecture
+--------------------+ +--------------------+
| | | |
| Source Code | | Source Code |
| (e.g., Hello.java) | | (e.g., hello.cpp) |
| | | |
+--------------------+ +--------------------+
| |
| |
v v
+--------------------+ +--------------------+
| | | Compiler |
| Java compiler | +--------------------+
| | |
+--------------------+ |
| v
| +--------------------+
v | Object code |
+---------------------+ | (e.g., hello.obj) |
| | +--------------------+
| Byte code | |
| (e.g., Hello.class) | v
| | +--------------------+
+---------------------+ | Linker |
| +--------------------+
| |
v v
+---------------------+ +--------------------+
|Java Virtual Machine | | Machine code |
| (JVM) | +--------------------+
| +---------------+ | |
| | OS | | v
| | +---------+ | | +-----------------+
| | | CPU | | | | OS |
| | +---------+ | | | +-----------+ |
| +---------------+ | | | CPU | |
+---------------------+ | +-----------+ |
+-----------------+
Java has both a compiler and a Virtual machine (an interpreter).
The compiler takes source code and translates it into another
simpler (but less human readable) language called byte code.
The byte code is executed during run time (while the program is running)
by the Java Virtual Machine (JVM).