Explain JVM (Java virtual machine) and JIT (Just-in-time compilation). JVM is a virtual computer that runs the compiled java program. JVM is a software that stays on the top of the operating system and provides abstraction between the compiled java program and operating system. This way, java compiled program doesn’t have to worry about which platform it has to work. The Java program compiles code into byte codes which JVM can understand and execute.
When JVM compiles the class file, it doesn’t compile the full class file; it compiles only a part of it on need basis. This avoids heavy parsing of complete source code. This type of compilation is termed as JIT or Just-In-Time compilation.
JVM Java Virtual Machine is acting as a machine for interpreting the byte code into a machine independent native code. The byte code is a portable binary form file, which can execute on various OS. It has a stack-based architecture. The byte code that is generated in Windows OS can run on Linux system. The corresponding JVM (or OS dependent JVM) converts the basic byte code instructions into executable form.
JIT Compiler JIT compiler coverts a byte code of one operating system to the current operating system’s executable code. This instruction is given by JVM of the current system. The byte is compiled into native platform code. The execution speed is greatly improved by this process, because the platform is directly executing the native byte code.
|