0% found this document useful (0 votes)
11 views

2 Java JVM, JDK and JRE

Introduction of JVM, JDK, JRE

Uploaded by

Bhuvana Gowtham
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

2 Java JVM, JDK and JRE

Introduction of JVM, JDK, JRE

Uploaded by

Bhuvana Gowtham
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Java JVM, JDK and JRE

Java virtual Machine(JVM)

• Java virtual Machine(JVM) provides runtime environment to execute java byte


code.

• 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

• It enables to run applications in a cloud environment or in our device.

• Converts byte code to machine-specific code.

• Provides basic java functions like memory management, security, garbage


collection, and more.

• 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

• Provides runtime environment( in which a program or application is executed)


JVM ARCHITECTURE
• Class Loader : Class loader loads the Class for execution.

• class area : Stores pre-class structure as constant pool.

• Heap : Heap is a memory area in which objects are allocated.

• Stack : It holds local variables and partial results, and plays a part in method

invocation and return.


• Program register : Program register holds the address of JVM instruction currently
being executed.

• Native method stack : It contains all the native methods used in the application.

• Executive Engine : Execution engine controls the execute of instructions contained


in the methods of the classes.

• 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

• A native method in Java is a method whose implementation is written in other


languages such as c and c++.

• The ‘native’ keyword is used before a method to indicate that it is implemented in


other language.
We can use native method to

• Implement an interface with system calls or libraries written in other


programming languages

• Access system or hardware resources that are only reachable from the other
language

• Integrate already existing code written in C/C++ into a java application


JRE (Java Runtime Environment)
JRE (Java Runtime Environment)

• Used to provide a runtime environment.

• Is the implementation of JVM.

• Contains a set of libraries + other files that JVM uses at runtime


JDK( Java Development Kit)
JDK( Java Development Kit)

• Is a software development environment which is used to develop java applications

and applets.

• It contains jre + development tools.


The workflow of JDK, JVM, and JRE :
• Just-In-Time Compiler(JIT) : It is used to increase the efficiency of an interpreter .
Differences between interpreter and compiler
Interpreter Compiler

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.

You might also like