- Basic work of compilers is translating source code into machine code for a specific computer.
- Java compiler also does the same thing.
- Java compiler generates an intermediate code known as byte code that can be run on any machine without recompiling it.
- This byte code is executed by the Java Virtual Machine
- It is an interpreter for the byte code.
- Byte Code is not machine specific.
- The machine specific code is generated by the Java Interpreter by acting as intermediate between the virtual machine and the real machine as shown in fig.
- Interpreters are different for different machines.
Bytecode
- When java programs are compiled, it does not produce output as executable code directly but java compiler translates source code into the bytecode
- Bytecode is intermediate set of instructions that JVM will execute
- Translating program code into byte code makes easy to allow program code to be a portable
- In fact bytecode is the mechanism that achieves goal of security and platform independent programs