The output of java complier is not an executable code, rather it is a bytecode.
- Byte code is a highly optimized set of instructions designed to be executed by the Java run-time system, which is called the Java Virtual Machine (JVM).
- JVM is a platform independent execution environment that converts Bytecode into machine codes and executes it.
- In a standard form, JVM is an interpreter for bytecode. Therefore, java programs are executed by JVM.
- Translating a Java program into bytecode helps makes it much easier to run a program in a wide variety of environments.
- The reason is straightforward: only the JVM needs to be implemented for each platform.
- The execution of every program is under the control of JVM, making Java secure.
- JVM enabling bytecode to be executed on any processor regardless of operating system. Hence making Java Platform Independent.
High performance:
- The java virtual machine (JVM) is an application, when installed on computer can actually run our java program (bytecode).
- The java program are complied into bytecode .The JVM reads and interprets the bytecode and converts it into machine code.
- The machine code will then be executed on the machine java programs. java programs are supposed to be originally interpreted by JVM .i.e exected , bytecode by bytecode but the interpretation can be slow process due to which ultimately the execution of the program becomes slower and thus the preformace can be degrade.
- However,the java2 provides just In Time(JIT)compiler, which is bulit into the JVM.The JIT compiler actually reads bytecodes into sections and compiles them to machine level language so that the program can run faster and thus high performance is obtained.Thus java programs will run faster with the JIT compiler.