Java Build Process

Machine Code vs. Native Code vs. Bytecode

Certain languages, such as Java and C#, compile into bytecode. Bytecode is an intermediate language that is platform agnostic. A platform specific JVM or CLR (common language runtime) is responsible for compiling the bytecode into machine code at runtime. Machine code is the lowest level code. It is direct instruction to the CPU, to perform low level operations such as arithmatic, logic, and data movement. Languages such as C and C++ compile directly to machine code. Lastly, native code, is machine code optimized for a specific CPU architecture and operating system.

JDK vs. JRE vs. JVM

The Java Development Kit includes all of the tools you need to write, test, debug, performance tune, and compile your code. There are several companies that produce and maintain JDKs such as: Oracle, OpenJDK, IBM, and Red Hat. The tools provided by the JDK include:

ToolDescription
javacCompiles java code (.java) into bytecode (.class).
javapAllows you to inspect the bytecode by disassembling it.
javaRuns the java bytecode on the JVM.
jdbA command-line Java debugger.
jconsoleA graphical monitoring tool for troubleshooting processing running on the JVM.
jmapUsed to peek into the heap memory of a running java process.
jvisualvmJava visual VM is visual tool for monitoring, troubleshooting, and profiling a java process.
jshellAn interactive java interpreter used for prototyping and experimenting.
jstatA command line tool used to monitor garbage collector activity.

Code compilation (turning a .java file to a .class file) only requires the JRE. No additional tools (aside from the javac) or libaries are needed.

The Java Runtime Environment is part of the JDK. It is everything needed to run your bytecode. It includes the JVM, Java core classes, and supporting files.

When a user invokes the java tool, the JRE loads the bytecode files, The bytecode is then interpreted line-by-line by the JVM into machine code.