java compiler
The Java literal translator
Core Concept
The main purpose
of a Java compiler
is to translate the
high-level Java source
code into a machine code
file consisting of machine-readable
0s and 1s, and then execute the file.
Super-smart, but very literal translator
Your job, as the Java Compiler (javac), is to meticulously read every single word of the instructions. You don't execute the instructions yourself; you just translate them into a simpler, universal, machine-friendly blueprint called bytecode (stored in a .class file).
While translating, you are extremely picky.
If the translation is successful,
you hand over the bytecode blueprint.
This blueprint isn't for any one specific machine;
it's written in a special intermediate language
that any machine with the right "interpreter".
(the Java Virtual Machine, or JVM)
can understand and execute.
This is what makes Java "Write Once, Run Anywhere."
# How a programmer typically runs the compiler from the command line
javac MyProgram.javaRelevant Concepts
- Garbage Collector :: Imagine the Garbage Collector as a destructor of unused Worlds (objects). No longer needed and where any life is created.
- Heap Space :: The dark matter of Java. Where new objects are stored.
- String Pool :: Space in the JVM Universe for storing Strings.
- Compiler Time Constants :: The compiler is like a cashier who, when she sees a compile-time constant, gets excited and instead of using the machine (runtime), does the calculations herself right there and then.
- Dynamic Dispatching :: The interface is like a contract. The compiler looks at the contract and sees if that clause exists. If it does, it lets the worker carry it out.