SlideShare a Scribd company logo
Java JDK, JRE and JVM
1. Executionof a Java Program
Before jumping into the internals of Java, let’s understand how a Java source
file is executed.
1. We write the Java sourcecodein Simple.Java file using an editor or IDE
(integrated development environment) e.g. Eclipse or IntelliJ Idea.
2. Program has to be compiled into bytecode. Java compiler (javac)
compiles the sourcecodeto Simple.class file.
3. This class file can be executed in any platform/OS by JVM (Java virtual
machine).
4. JVM translates bytecodeinto native machine codewhich machines can
execute.
Java Execution Flow
2. What is JVM?
Java Virtual machine (JVM) is the virtual machine that runs the Java
bytecodes. You get this bytecodeby compiling the .java files
into .class files. .class files contain the bytecodes understood by the JVM.
3.6M
[Fix] Error formatting volume in Ubuntu and other Linux distributions
Next
Stay
In the real world, JVM is a specification that provides a runtime environment in
which Java bytecodecan be executed. Different vendors provide different
implementations of this specification. Forexample, this wiki page lists
down different JVM implementations.
Most popular implementation of JVM is Hotspot which is owned and provided
by Oracle Corporation. (Previously by Sun Microsystems, Inc.).
JVM delivers the optimal performance for Java applications using many
advanced techniques, incorporating a state-of-the-art memory model, garbage
collector, and adaptive optimizer.
JVM comes in two different flavors – client and server. Although the Server
and the Client VMs are similar, the Server VM has been specially tuned to
maximize peak operating speed. It is intended for executing long-running server
applications, which need the fastest possible operating speed more than a fast
start-up time or smaller runtime memory footprint. Developers can choose
which system they want by specifying -client or -server.
The JVM is called virtual becauseit provides a machine interface that does not
depend on the underlying operating system and machine hardware architecture.
This independence from hardware and the operating system is a cornerstone of
the write-once-run-anywhere value of Java programs.
2.1. JVM Architecture
JVM Architecture
2.1.1. ClassLoader
The class loader is a subsystem used for loading class files. It performs three
primary functions, i.e. class loading, linking, and initialization.
1. Loading
 To load classes, JVM has 3 kind of class
loaders. Bootstrap, extensionand application class loader.
 When loading a class file, JVM finds out a dependencyfor some
arbitrary class XYZ.class.
 First bootstrap class loader tries to find the class. It scans
the rt.jar file in JRE lib folder.
 If class is not found then extension class loader searches the class
file in inside jrelibext folder.
 Again if class is not found then application classloader searches all
the Jar files and classes in CLASSPATH environment variable of
system.
 If class is found by any loader then class is loaded by class loader;
else ClassNotFoundException is thrown.
2. Linking
After class is loaded by the classloader, linking is performed. A bytecode
verifier will verify whether the generated bytecodeis proper or not. If
verification fails we will get a verification error. It also performs the memory
allocation to static variables and methods found in the class.
3. Initialization
This is the final phase of class loading, here all static variable will be assigned
with the original values, and the static blocks will be executed.
2.1.2. JVM Memory Areas
The memory area inside JVM is divided into multiple parts to store specific
pieces of application data.
 Method Area stores class structures like metadata, the constant runtime
pool, and the codefor methods.
 Heap stores all objects that are created during application execution.
 Stacks storelocal variables, and intermediate results. All suchvariables
are local to the thread by which they are created. Each thread has its own
JVM stack, created simultaneously as the thread is created. So all such
local variable are called thread-local variables.
 PC registerstorethe physical memory address of the statements which is
currently executing. In Java, each thread has its separate PC register.
 Java supports and uses native code as well. Many low level codeis
written in languages like C and C++. Native method stacks hold the
instruction of native code.
2.2. JVM ExecutionEngine
All codeassigned to JVM is executed by an execution engine. The execution
engine reads the byte codeand executes one by one. It uses two
inbuilt interpreter and JIT compiler to convert the bytecode to machine code
and execute it.
Platform Specific
Interpreters
With JVM, both interpreter and compiler producenative code. The difference is
in how they generate the native code, how optimized it is as well how costly the
optimization is.
2.2.1. Interpreter
A JVM interpreter pretty much converts each byte-codeinstruction to
corresponding native instruction by looking up a predefined JVM-instruction to
machine instruction mapping. It directly executes the bytecodeand does not
perform any optimization.
2.2.2. JIT Compiler
To improve performance, JIT compilers interact with the JVM at runtime and
compile appropriate bytecodesequences into native machine code. Typically,
the JIT compiler takes a block of code(not one statement at a time as
interpreter), optimizes the code, and then translates it to optimized machine
code.
The JIT compiler is enabled by default. You can disable the JIT compiler, in
which case the entire Java program will be interpreted. Disabling the JIT
compiler is not recommended except to diagnose or workaround JIT
compilation problems.
3. What is JRE?
The Java Runtime Environment (JRE) is a software package which bundles
the libraries (jars) and the Java Virtual Machine, and other components to run
applications written in the Java. JVM is just a part of JRE distributions.
To execute any Java application, you need JRE installed in the machine. It’s the
minimum requirement to run Java applications on any computer.
JRE bundles the following components –
1. DLL files used by the Java HotSpot Client Virtual Machine.
2. DLL files used by the Java HotSpot Server Virtual Machine.
3. Code libraries, property settings, and resource files used by the Java
runtime environment. e.g. rt.jar and charsets.jar.
4. Java extensionfiles such as localedata.jar.
5. Contains files used for security management. These include the security
policy (java.policy) and security properties (java.security) files.
6. Jar files containing supportclasses for applets.
7. Contains TrueType font files for use by the platform.
JREs can be downloaded as part of JDKs, or you can download them separately.
JREs are platform dependent. It means that based on the type of machine (OS
and architecture), you will have to select the JRE bundle to import and install.
For example, you cannot install a 64-bit JRE distribution on 32-bit machine.
Similarly, JRE distribution for Windowswill not work in Linux;and vice-versa.
4. What is JDK?
JDK is a supersetof JRE. JDK contains everything that JRE has along with
development tools for developing, debugging, and monitoring Java applications.
You need JDK when you need to develop Java applications.
Few important components shipped with JDKs are as follows:
 appletviewer– this tool can be used to run and debug Java applets
without a web browser
 apt – the annotation-processing tool
 extcheck – a utility that detects JAR file conflicts
 javadoc – the documentation generator, which automatically generates
documentation from sourcecodecomments
 jar – the archiver, which packages related class libraries into a single
JAR file. This tool also helps manage JAR files
 jarsigner– the jar signing and verification tool
 javap – the class file disassembler
 javaws – the Java Web Start launcher for JNLP applications
 JConsole – Java Monitoring and Management Console
 jhat – Java Heap Analysis Tool
 jrunscript – Java command-line script shell
 jstack – utility that prints Java stack traces of Java threads
 keytool – toolfor manipulating the keystore
 policytool – the policy creation and management tool
 xjc – Part of the Java API for XML Binding (JAXB) API. It accepts an
XML schema and generates Java classes
Same as JREs, JDKs are also platform dependent. So take care when you
download the JDK package for your machine.
5. Difference betweenJDK, JRE and JVM
Based on the above discussions, we can draw a relationship between these three
as below –
JRE = JVM + libraries to run Java application.
JDK = JRE + tools to develop Java Application.

More Related Content

Similar to Java JDK.docx

Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machineLaxman Puri
 
JAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxJAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxMurugesh33
 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxMurugesh33
 
Top 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdfTop 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdfUmesh Kumar
 
JRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVAJRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVAMehak Tawakley
 
JVM Architecture – How It Works.pdf
JVM Architecture – How It Works.pdfJVM Architecture – How It Works.pdf
JVM Architecture – How It Works.pdfGeekster
 
A begineers guide of JAVA - Getting Started
 A begineers guide of JAVA - Getting Started A begineers guide of JAVA - Getting Started
A begineers guide of JAVA - Getting StartedRakesh Madugula
 
Java programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, MysuruJava programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, MysuruNithin Kumar,VVCE, Mysuru
 
Introduction to java programming tutorial
Introduction to java programming   tutorialIntroduction to java programming   tutorial
Introduction to java programming tutorialjackschitze
 

Similar to Java JDK.docx (20)

Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machine
 
JAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxJAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptx
 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptx
 
Java chapter 1
Java   chapter 1Java   chapter 1
Java chapter 1
 
Java unit 1
Java unit 1Java unit 1
Java unit 1
 
Top 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdfTop 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdf
 
JRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVAJRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVA
 
JVM Architecture – How It Works.pdf
JVM Architecture – How It Works.pdfJVM Architecture – How It Works.pdf
JVM Architecture – How It Works.pdf
 
A begineers guide of JAVA - Getting Started
 A begineers guide of JAVA - Getting Started A begineers guide of JAVA - Getting Started
A begineers guide of JAVA - Getting Started
 
JDK,JRE,JVM
JDK,JRE,JVMJDK,JRE,JVM
JDK,JRE,JVM
 
Java ms harsha
Java ms harshaJava ms harsha
Java ms harsha
 
2. hello java
2. hello java2. hello java
2. hello java
 
java intro.pptx
java intro.pptxjava intro.pptx
java intro.pptx
 
Java presentation
Java presentation Java presentation
Java presentation
 
Java basic
Java basicJava basic
Java basic
 
Java programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, MysuruJava programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, Mysuru
 
Introduction to java programming tutorial
Introduction to java programming   tutorialIntroduction to java programming   tutorial
Introduction to java programming tutorial
 
Introduction java programming
Introduction java programmingIntroduction java programming
Introduction java programming
 
What is-java
What is-javaWhat is-java
What is-java
 
Jvm internal detail
Jvm internal detailJvm internal detail
Jvm internal detail
 

Recently uploaded

Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfMayankTawar1
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfAMB-Review
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Globus
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsGlobus
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesGlobus
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfGlobus
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of ProgrammingMatt Welsh
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowPeter Caitens
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEJelle | Nordend
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?XfilesPro
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageGlobus
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Globus
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxvarshanayak241
 

Recently uploaded (20)

Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
 

Java JDK.docx

  • 1. Java JDK, JRE and JVM 1. Executionof a Java Program Before jumping into the internals of Java, let’s understand how a Java source file is executed. 1. We write the Java sourcecodein Simple.Java file using an editor or IDE (integrated development environment) e.g. Eclipse or IntelliJ Idea. 2. Program has to be compiled into bytecode. Java compiler (javac) compiles the sourcecodeto Simple.class file. 3. This class file can be executed in any platform/OS by JVM (Java virtual machine). 4. JVM translates bytecodeinto native machine codewhich machines can execute. Java Execution Flow 2. What is JVM? Java Virtual machine (JVM) is the virtual machine that runs the Java bytecodes. You get this bytecodeby compiling the .java files into .class files. .class files contain the bytecodes understood by the JVM. 3.6M [Fix] Error formatting volume in Ubuntu and other Linux distributions Next Stay
  • 2. In the real world, JVM is a specification that provides a runtime environment in which Java bytecodecan be executed. Different vendors provide different implementations of this specification. Forexample, this wiki page lists down different JVM implementations. Most popular implementation of JVM is Hotspot which is owned and provided by Oracle Corporation. (Previously by Sun Microsystems, Inc.). JVM delivers the optimal performance for Java applications using many advanced techniques, incorporating a state-of-the-art memory model, garbage collector, and adaptive optimizer. JVM comes in two different flavors – client and server. Although the Server and the Client VMs are similar, the Server VM has been specially tuned to maximize peak operating speed. It is intended for executing long-running server applications, which need the fastest possible operating speed more than a fast start-up time or smaller runtime memory footprint. Developers can choose which system they want by specifying -client or -server. The JVM is called virtual becauseit provides a machine interface that does not depend on the underlying operating system and machine hardware architecture. This independence from hardware and the operating system is a cornerstone of the write-once-run-anywhere value of Java programs. 2.1. JVM Architecture
  • 3. JVM Architecture 2.1.1. ClassLoader The class loader is a subsystem used for loading class files. It performs three primary functions, i.e. class loading, linking, and initialization. 1. Loading  To load classes, JVM has 3 kind of class loaders. Bootstrap, extensionand application class loader.  When loading a class file, JVM finds out a dependencyfor some arbitrary class XYZ.class.  First bootstrap class loader tries to find the class. It scans the rt.jar file in JRE lib folder.  If class is not found then extension class loader searches the class file in inside jrelibext folder.  Again if class is not found then application classloader searches all the Jar files and classes in CLASSPATH environment variable of system.  If class is found by any loader then class is loaded by class loader; else ClassNotFoundException is thrown.
  • 4. 2. Linking After class is loaded by the classloader, linking is performed. A bytecode verifier will verify whether the generated bytecodeis proper or not. If verification fails we will get a verification error. It also performs the memory allocation to static variables and methods found in the class. 3. Initialization This is the final phase of class loading, here all static variable will be assigned with the original values, and the static blocks will be executed. 2.1.2. JVM Memory Areas The memory area inside JVM is divided into multiple parts to store specific pieces of application data.  Method Area stores class structures like metadata, the constant runtime pool, and the codefor methods.  Heap stores all objects that are created during application execution.  Stacks storelocal variables, and intermediate results. All suchvariables are local to the thread by which they are created. Each thread has its own JVM stack, created simultaneously as the thread is created. So all such local variable are called thread-local variables.  PC registerstorethe physical memory address of the statements which is currently executing. In Java, each thread has its separate PC register.  Java supports and uses native code as well. Many low level codeis written in languages like C and C++. Native method stacks hold the instruction of native code. 2.2. JVM ExecutionEngine All codeassigned to JVM is executed by an execution engine. The execution engine reads the byte codeand executes one by one. It uses two inbuilt interpreter and JIT compiler to convert the bytecode to machine code and execute it.
  • 5. Platform Specific Interpreters With JVM, both interpreter and compiler producenative code. The difference is in how they generate the native code, how optimized it is as well how costly the optimization is. 2.2.1. Interpreter A JVM interpreter pretty much converts each byte-codeinstruction to corresponding native instruction by looking up a predefined JVM-instruction to machine instruction mapping. It directly executes the bytecodeand does not perform any optimization. 2.2.2. JIT Compiler To improve performance, JIT compilers interact with the JVM at runtime and compile appropriate bytecodesequences into native machine code. Typically, the JIT compiler takes a block of code(not one statement at a time as interpreter), optimizes the code, and then translates it to optimized machine code. The JIT compiler is enabled by default. You can disable the JIT compiler, in which case the entire Java program will be interpreted. Disabling the JIT compiler is not recommended except to diagnose or workaround JIT compilation problems. 3. What is JRE? The Java Runtime Environment (JRE) is a software package which bundles the libraries (jars) and the Java Virtual Machine, and other components to run applications written in the Java. JVM is just a part of JRE distributions. To execute any Java application, you need JRE installed in the machine. It’s the minimum requirement to run Java applications on any computer. JRE bundles the following components – 1. DLL files used by the Java HotSpot Client Virtual Machine.
  • 6. 2. DLL files used by the Java HotSpot Server Virtual Machine. 3. Code libraries, property settings, and resource files used by the Java runtime environment. e.g. rt.jar and charsets.jar. 4. Java extensionfiles such as localedata.jar. 5. Contains files used for security management. These include the security policy (java.policy) and security properties (java.security) files. 6. Jar files containing supportclasses for applets. 7. Contains TrueType font files for use by the platform. JREs can be downloaded as part of JDKs, or you can download them separately. JREs are platform dependent. It means that based on the type of machine (OS and architecture), you will have to select the JRE bundle to import and install. For example, you cannot install a 64-bit JRE distribution on 32-bit machine. Similarly, JRE distribution for Windowswill not work in Linux;and vice-versa. 4. What is JDK? JDK is a supersetof JRE. JDK contains everything that JRE has along with development tools for developing, debugging, and monitoring Java applications. You need JDK when you need to develop Java applications. Few important components shipped with JDKs are as follows:  appletviewer– this tool can be used to run and debug Java applets without a web browser  apt – the annotation-processing tool  extcheck – a utility that detects JAR file conflicts  javadoc – the documentation generator, which automatically generates documentation from sourcecodecomments  jar – the archiver, which packages related class libraries into a single JAR file. This tool also helps manage JAR files  jarsigner– the jar signing and verification tool  javap – the class file disassembler  javaws – the Java Web Start launcher for JNLP applications  JConsole – Java Monitoring and Management Console  jhat – Java Heap Analysis Tool
  • 7.  jrunscript – Java command-line script shell  jstack – utility that prints Java stack traces of Java threads  keytool – toolfor manipulating the keystore  policytool – the policy creation and management tool  xjc – Part of the Java API for XML Binding (JAXB) API. It accepts an XML schema and generates Java classes Same as JREs, JDKs are also platform dependent. So take care when you download the JDK package for your machine. 5. Difference betweenJDK, JRE and JVM Based on the above discussions, we can draw a relationship between these three as below – JRE = JVM + libraries to run Java application. JDK = JRE + tools to develop Java Application.