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

java_2

The document provides an overview of the Java Development Kit (JDK) architecture, detailing components such as the Java Runtime Environment (JRE), Java Virtual Machine (JVM), and Java Class Libraries. It explains the roles of the Java Compiler, Execution Engine, and Garbage Collector, as well as the structure of the JVM including the method area, heap area, and stack. Additionally, it covers the use of the Java Native Interface (JNI) for integrating native methods and libraries from other programming languages.

Uploaded by

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

java_2

The document provides an overview of the Java Development Kit (JDK) architecture, detailing components such as the Java Runtime Environment (JRE), Java Virtual Machine (JVM), and Java Class Libraries. It explains the roles of the Java Compiler, Execution Engine, and Garbage Collector, as well as the structure of the JVM including the method area, heap area, and stack. Additionally, it covers the use of the Java Native Interface (JNI) for integrating native methods and libraries from other programming languages.

Uploaded by

Vaishnavi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

JEAD

JDK, JVM, JRE

Session-3

- Santosh Katti, Department of Computer Applications, PESU


JEAD
JDK Architecture

Java Runtime Environment (JRE)

Java Virtual Machine (JVM): Executes the compiled


bytecode. It translates bytecode into machine code
specific to the host operating system and hardware.

Java Class Libraries: A set of dynamically loadable


libraries that Java applications can call at runtime. This
includes essential classes such as data structures,
networking, input/output, and more.

- Santosh Katti, Department of Computer Applications, PESU


JEAD
JDK Architecture

Java Compiler (javac)Converts Java source code


(.java files) into bytecode (.class files).Bytecode
is platform-independent and can be executed
by the Java Virtual Machine (JVM).

Tools like javap (Java Class File Disassembler),


javadoc (documentation generator), jdb (Java
Debugger), and others help developers write,
debug, and document their code.

- Santosh Katti, Department of Computer Applications, PESU


JEAD
JVM - Architecture

Bootstrap: Loads std. classes like


lang, util, io etc.
(lib folder)

Extention: std. libraries


(lib/ext folder)

Application: libraries from


ClassPath-current dir

Verify: Java 11 on Java 8?

Prepare: init. Static variables

Resolve: Symbolic constants from


other classes/references
- Santosh Katti, Department of Computer Applications, PESU
JEAD
JVM - Architecture

Method Area: All the class


level data such as the run-
time constant pool, field,
and method data, and the
code for methods and
constructors, are stored
here.

If the memory available in


the method area is not
sufficient for the program The field level data (class members) and the constructor details
startup, the JVM throws an are loaded into the method area.
OutOfMemoryError.
The method area is created on the virtual machine start-up,
and there is only one method area per JVM.

- Santosh Katti, Department of Computer Applications, PESU


JEAD
JVM - Architecture

Heap Area: All the objects


and their corresponding
instance variables are
stored here. This is the run-
time data area from which
memory for all class
instances and arrays is
allocated.

The heap is created on the virtual machine start-up, and there


is only one heap area per JVM.

- Santosh Katti, Department of Computer Applications, PESU


JEAD
JVM - Architecture

Stack: Whenever a new


thread is created in the
JVM, a separate runtime
stack is also created at the
same time. All local
variables, method calls, and
partial results are stored in
the stack area.

If the processing being


done in a thread requires a For every method call, one entry is made in the stack memory
larger stack size than which is called the Stack Frame. When the method call is
what's available, the JVM complete, the Stack Frame is destroyed.
throws a
StackOverflowError.

- Santosh Katti, Department of Computer Applications, PESU


JEAD
JVM - Architecture

Local Variables – Each


frame contains an array of
variables known as its local
variables. All local variables
and their values are stored
here. The length of this
array is determined at
compile-time.

Operand Stack – Each frame contains a last-in-first-out (LIFO) stack known as its operand stack.
This acts as a runtime workspace to perform any intermediate operations. The maximum depth
of this stack is determined at compile-time.

Frame Data – All symbols corresponding to the method are stored here. This also stores the
catch block information in case of exceptions.

- Santosh Katti, Department of Computer Applications, PESU


JEAD
JVM - Architecture

Program Counter (PC)


Registers
The JVM supports multiple
threads at the same time.
Each thread has its own PC
Register to hold the
address of the currently
executing JVM instruction.
Once the instruction is
executed, the PC register is Native Method Stacks
updated with the next The JVM contains stacks that support native methods. These
instruction. methods are written in a language other than the Java, such
as C and C++. For every new thread, a separate native
method stack is also allocated.

- Santosh Katti, Department of Computer Applications, PESU


JEAD
JVM - Architecture

Execution Engine
Once the bytecode has been loaded into the main memory, and details are available in the
runtime data area, the next step is to run the program. The Execution Engine handles this
by executing the code present in each class.

However, before executing the program, the bytecode needs to be converted into
machine language instructions. The JVM can use an interpreter or a JIT compiler for the
execution engine.

- Santosh Katti, Department of Computer Applications, PESU


JEAD
JVM - Architecture

Interpreter
The interpreter reads and
executes the bytecode
instructions line by line.
Due to the line by line JIT Compiler
execution, the interpreter is The JIT Compiler overcomes the disadvantage of the
comparatively slower. interpreter. The Execution Engine first uses the interpreter to
execute the byte code, but when it finds some repeated code,
Another disadvantage of it uses the JIT compiler.
the interpreter is that when
a method is called multiple The JIT compiler then compiles the entire bytecode and
times, every time a new changes it to native machine code. This native machine code is
interpretation is required.. used directly for repeated method calls, which improves the
performance of the system.

for(i=1; i<10; i++)


sum+=i;
- Santosh Katti, Department of Computer Applications, PESU
JEAD
JVM - Architecture

Garbage Collector
The Garbage Collector (GC)
collects and removes
unreferenced objects from
the heap area. It is the
process of reclaiming the Java Native Interface (JNI)
runtime unused memory JNI acts as a bridge for permitting the supporting packages for
automatically by destroying other programming languages such as C, C++, and so on. This is
them. especially helpful in cases where you need to write code that is
not entirely supported by Java, like some platform specific
Garbage collection makes features that can only be written in C.
Java memory efficient
because it removes the Native Method Libraries
unreferenced objects from Native Method Libraries are libraries that are written in other
heap memory and makes programming languages, such as C, C++, and assembly. These
free space for new objects. libraries are usually present in the form of .dll or .so files. These
native libraries can be loaded through JNI.
- Santosh Katti, Department of Computer Applications, PESU

You might also like