2 Java JVM, JDK and JRE
2 Java JVM, JDK and JRE
• Is an abstract machine.
• The JVM doesn't understand normal English lang, that's why we compile our
*.java files to obtain *.class files that contain the bytecodes understandable by the
JVM.
Important features of JVM are
• JVM runs the program by using libraries and files given by the Java Runtime
Environment.
• JDK and JRE both contain Java Virtual Machine.
• It can execute the java program line by line hence it is also called an interpreter.
• JVM is easily customizable for example, we can allocate minimum and maximum
memory to it.
• It is independent of hardware and the operating system. So, we can write a java
program once and run it anywhere.
The JVM performs following operation:
• Loads code
• Verifies code
• Executes code
• Stack : It holds local variables and partial results, and plays a part in method
• Native method stack : It contains all the native methods used in the application.
• Native Method Interface : Native method interface gives an interface between java
code and native code during execution.
• Native Method Libraries : Native Libraries consist of files required for the
execution of native code.
native method
• Access system or hardware resources that are only reachable from the other
language
and applets.
Interpreter translates just one statement of the program Compiler scans the entire program and translates the
at a time into machine code. whole of it into machine code at once.
An interpreter takes very less time to analyze the A compiler takes a lot of time to analyze the source
source code. However, the overall time to execute the code. However, the overall time taken to execute the
process is much slower. process is much faster.
It does not convert source code into object code instead It converts the source code into object code.
it scans it line by line
Keeps translating the program continuously till the first A compiler generates the error message only after it
error is confronted. If any error is spotted, it stops scans the complete program and hence debugging is
working and hence debugging becomes easy. relatively harder while working with a compiler.
Interpreters are used by programming languages like Compliers are used by programming languages like C
Ruby and Python for example. and C++ for example.