SlideShare une entreprise Scribd logo
1  sur  31
Télécharger pour lire hors ligne
Java Compiler and Runtime
Omar Bashir
@OmarBashir_40 obashir@yahoo.com
Java: Write Once Run Anywhere
Java Source Code (.java files)
Java: Write Once Run Anywhere
Java Source Code (.java files) Java Compiler
Java: Write Once Run Anywhere
Java Source Code (.java files) Java Compiler Java Bytecode (.class files)
Java: Write Once Run Anywhere
Java Source Code (.java files) Java Compiler Java Bytecode (.class files)
Java Virtual Machine
Java: Write Once Run Anywhere
Java Source Code (.java files) Java Compiler Java Bytecode (.class files)
Java Virtual Machine
Interpreted
platform specific
instructions
Any Hardware
Java Virtual Machine (JVM)
● A virtual computer that executes Java bytecode.
– A platform specific program giving Java its platform
independence.
● Key JVM concepts,
– Specification
● Abstract definition omitting irrelevant implementation details.
– Implementation
● Platform specific implementation that executes bytecode.
– Instance
● Each Java application is executed in a separate JVM instance.
● Launched by executing the java command.
Java HotSpotTM
Virtual Machine
● Oracle's/Sun's JVM implementation.
● Key features
– JIT (Just In Time) compilation
● Compilation of specific program sections to native instructions
and caching them.
– Adaptive optimisation
● Dynamic recompilation of program sections based on current
execution profiles.
● Generational garbage collection
– Disposing unused objects and reclaiming memory.
JVM Architecture
Class Loader
Compiled
Classes
JVM Runtime Memory
Heap
Method Area
Java Stack
Native Method Stack
Program Counter Registers
Execution Engine Native Interface
Native
Libraries
Thread common memory Thread specific memory
Code Cache
JVM Architecture
Thread common memory Thread specific memoryThread common memory
Dynamic on demand loading of Java
classes from the classpath
1. Loading bytecode,
2. Linking,
3. Variable initialisation
Class Loader
Compiled
Classes
JVM Runtime Memory
Heap
Method Area
Java Stack
Native Method Stack
Program Counter Registers
Execution Engine Native Interface
Native
Libraries
Code Cache
JVM Architecture
Thread common memory Thread specific memory
Heap contains
instances of classes,
i.e., objects. Heap is
garbage collected to
remove unused objects.
Class Loader
Compiled
Classes
JVM Runtime Memory
Heap
Method Area
Java Stack
Native Method Stack
Program Counter Registers
Execution Engine Native Interface
Native
Libraries
Code Cache
JVM Architecture
Thread common memory Thread specific memory
Method Area stores
information regarding
loaded classes, their
fields, methods and
values of class
variables. Also referred
to as Perm Gen, it no
longer exists in Java 8.
Class Loader
Compiled
Classes
JVM Runtime Memory
Heap
Method Area
Java Stack
Native Method Stack
Program Counter Registers
Execution Engine Native Interface
Native
Libraries
Code Cache
JVM Architecture
Thread common memory Thread specific memory
Code cache stores
methods that have
been compiled to
native code.
Class Loader
Compiled
Classes
JVM Runtime Memory
Heap
Method Area
Java Stack
Native Method Stack
Program Counter Registers
Execution Engine Native Interface
Native
Libraries
Code Cache
JVM Architecture
Thread common memory Thread specific memory
Stacks are per thread memory
frames organised in LIFO (Last
In First Out) structure.
Class Loader
Compiled
Classes
JVM Runtime Memory
Heap
Method Area
Java Stack
Native Method Stack
Program Counter Registers
Execution Engine Native Interface
Native
Libraries
Code Cache
JVM Architecture
Thread common memory Thread specific memory
Program counter and three
registers manage the stack.
Stack-oriented design helps
keep the JVM's instruction set
and implementation small.
Program counter tracks
instructions to be executed.
optop register points to the top
of operand stack, the
workspace.
frame register points to
operations of the stack.
vars register points to the local
variables sections.
Class Loader
Compiled
Classes
JVM Runtime Memory
Heap
Method Area
Java Stack
Native Method Stack
Program Counter Registers
Execution Engine Native Interface
Native
Libraries
Code Cache
JRE
Java Runtime Environment (JRE)
JVM
Java Class
Library
Package needed to run a Java application
JDK
Java Development Kit (JDK)
JRE
JVM
Java Class
Library
Java
Development
Tools
javac – Java Compiler
● Part of JDK
● Reads Java class and interface files and compiles
them into bytecode class files.
– Source files have .java extensions.
– Bytecode files have .class extensions.
● Syntax
– javac [options] [sources] [classes] [@argfiles]
● options: Command line options.
● sources: Source files.
● classes: Classes to be processed for annotations.
● argfiles: Files listing options and source files.
javac – Java Compiler
● Most frequently used options,
– -cp: Classpath, i.e., path to dependencies.
– -d: directory containing the compiled classes.
– -deprecation: Shows a description of each use of
a deprecated member or class.
– -g: Generate debugging information.
javac – Java Compiler (Example)
code
bin
src
app
calc
CalcApp.java
Calculator.java
javac src/*/*.java ­d bin 
javac – Java Compiler (Example)
code
bin
src
app
calc
CalcApp.java
Calculator.java
app
calc
CalcApp.class
Calculator.class
java – Launch Java Application in JVM
● Syntax
– java [options] main-class [arguments …]
– java [options] -jar file.jar [arguments …]
● Most frequently used options,
– -cp: Classpath, path to libraries and class files.
– -Dproperty=value: set a system property.
– -Xmsn: Minimum heap size.
– -Xmxn: Maximum heap size.
– -Xssn: Stack size.
java Demo
jar – Java Archive
● Grouping class files into libraries and java executables.
– Convenient packaging and deployment.
– Based on the zip file format.
– Command syntax closely related to tar
● Syntax
– Creation,
● jar cf jarfile input-files
● jar cmf manifest jarfile input-files
– Extraction
● jar xf jarfile
● Manifests provide,
– Versioning, signing, specifying classpaths, java executable.
jar Demo
Garbage Collection
● JVM relieves coders from deleting unused objects.
● Unused objects are deleted from the heap by the
Garbage Collector (GC).
– i.e., objects whose reference is not assigned to any variable.
● Each application has two threads at least,
– Thread running main,
– Thread running GC.
● When the GC thread runs, all other threads may pause
(Dependant on GC implementation).
– GC's execution is non-deterministic.
– Results in Java not being suitable for applications with strict
timing constraints (i.e., real-time applications).
Garbage Collection
Marking
Deletion
Compaction
Referenced
Unreferenced
Free
Garbage Collection
● Young generation
– New objects created.
– Minor garbage collection removes dead objects.
– Surviving objects aged and moved to old generation.
● Old generation
– Long surviving objects.
– Major garbage collection removes dead objects.
● Permanent generation
– Metadata of methods and classes for the JVM
Eden S0 S1Eden Tenured Permanent
Young Generation
Survivor
Space
Old Generation Permanent Generation
Garbage Collection
Example
import java.util.ArrayList;
import java.util.List;
public class DemoGc {
public static void main(String[] args) {
    wait1Minute();
for(int i = 0 ; i < 1000000; i++) {
List<Double> products = new ArrayList<Double>();
for(int j = 0; j < 1000; j++) {
products.add(i * j * 1.0);
}
System.out.print("***** " + i + "r");
}
}
  private static void wait1Minute() {
    try {
      Thread.sleep(60000);
    } catch (Exception exp) {}
  }
}
Garbage Collection Example
java ­Xms512m ­Xmx1024m DemoGc
An Introduction to Java Compiler and Runtime

Contenu connexe

Tendances

Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core javamahir jain
 
Compiler Construction Course - Introduction
Compiler Construction Course - IntroductionCompiler Construction Course - Introduction
Compiler Construction Course - IntroductionMuhammad Sanaullah
 
Fundamentals of JAVA
Fundamentals of JAVAFundamentals of JAVA
Fundamentals of JAVAKUNAL GADHIA
 
Java presentation
Java presentationJava presentation
Java presentationsurajdmk
 
What Is Java | Java Tutorial | Java Programming | Learn Java | Edureka
What Is Java | Java Tutorial | Java Programming | Learn Java | EdurekaWhat Is Java | Java Tutorial | Java Programming | Learn Java | Edureka
What Is Java | Java Tutorial | Java Programming | Learn Java | EdurekaEdureka!
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)arvind pandey
 
basics of compiler design
basics of compiler designbasics of compiler design
basics of compiler designPreeti Katiyar
 
Communication between Java and Python
Communication between Java and PythonCommunication between Java and Python
Communication between Java and PythonAndreas Schreiber
 
Report summer training core java
Report summer training core javaReport summer training core java
Report summer training core javaSudhanshuVijay3
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)slire
 
Introduction to java
Introduction to java Introduction to java
Introduction to java Java Lover
 
Basic concepts for python web development
Basic concepts for python web developmentBasic concepts for python web development
Basic concepts for python web developmentNexSoftsys
 
Lecture 1 introduction to vb.net
Lecture 1   introduction to vb.netLecture 1   introduction to vb.net
Lecture 1 introduction to vb.netMUKALU STEVEN
 
Automatizando seus testes com robot framework
Automatizando seus testes com robot frameworkAutomatizando seus testes com robot framework
Automatizando seus testes com robot frameworkClaudenir Freitas
 

Tendances (20)

Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
 
Compiler Construction Course - Introduction
Compiler Construction Course - IntroductionCompiler Construction Course - Introduction
Compiler Construction Course - Introduction
 
Fundamentals of JAVA
Fundamentals of JAVAFundamentals of JAVA
Fundamentals of JAVA
 
Java presentation
Java presentationJava presentation
Java presentation
 
Junit
JunitJunit
Junit
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
What Is Java | Java Tutorial | Java Programming | Learn Java | Edureka
What Is Java | Java Tutorial | Java Programming | Learn Java | EdurekaWhat Is Java | Java Tutorial | Java Programming | Learn Java | Edureka
What Is Java | Java Tutorial | Java Programming | Learn Java | Edureka
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 
basics of compiler design
basics of compiler designbasics of compiler design
basics of compiler design
 
Core java
Core javaCore java
Core java
 
Communication between Java and Python
Communication between Java and PythonCommunication between Java and Python
Communication between Java and Python
 
Report summer training core java
Report summer training core javaReport summer training core java
Report summer training core java
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 
Introduction to Eclipse IDE
Introduction to Eclipse IDEIntroduction to Eclipse IDE
Introduction to Eclipse IDE
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
Java Notes
Java NotesJava Notes
Java Notes
 
Basic concepts for python web development
Basic concepts for python web developmentBasic concepts for python web development
Basic concepts for python web development
 
Lecture 1 introduction to vb.net
Lecture 1   introduction to vb.netLecture 1   introduction to vb.net
Lecture 1 introduction to vb.net
 
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
 
Automatizando seus testes com robot framework
Automatizando seus testes com robot frameworkAutomatizando seus testes com robot framework
Automatizando seus testes com robot framework
 

Similaire à An Introduction to Java Compiler and Runtime

Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machineLaxman Puri
 
It pro dev_birbilis_20101127_en
It pro dev_birbilis_20101127_enIt pro dev_birbilis_20101127_en
It pro dev_birbilis_20101127_enGeorge Birbilis
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machineNikhil Sharma
 
Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...
Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...
Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...Rhythm Suiwal
 
A Brief study on JVM A Brief study on JVM
A Brief study on JVM A Brief study on JVMA Brief study on JVM A Brief study on JVM
A Brief study on JVM A Brief study on JVMBRNSSPublicationHubI
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunningguest1f2740
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance TunningTerry Cho
 
Java Virtual Machine - Internal Architecture
Java Virtual Machine - Internal ArchitectureJava Virtual Machine - Internal Architecture
Java Virtual Machine - Internal Architecturesubnesh
 
JVM, JRE and Javac are the main part for the java program
 JVM, JRE and Javac are the main part for the java program JVM, JRE and Javac are the main part for the java program
JVM, JRE and Javac are the main part for the java programsiyaram ray
 
Lecture 2 Java Virtual Machine .pptx
Lecture 2 Java Virtual Machine .pptxLecture 2 Java Virtual Machine .pptx
Lecture 2 Java Virtual Machine .pptxAnupamKumar559254
 
Android Training Chandigarh
Android Training ChandigarhAndroid Training Chandigarh
Android Training ChandigarhSheetal Sharma
 
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
 
imperative programming language, java, android
imperative programming language, java, androidimperative programming language, java, android
imperative programming language, java, androidi i
 

Similaire à An Introduction to Java Compiler and Runtime (20)

Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machine
 
Java Basic PART I
Java Basic PART IJava Basic PART I
Java Basic PART I
 
It pro dev_birbilis_20101127_en
It pro dev_birbilis_20101127_enIt pro dev_birbilis_20101127_en
It pro dev_birbilis_20101127_en
 
Java introduction
Java introductionJava introduction
Java introduction
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
 
Basic Java I
Basic Java IBasic Java I
Basic Java I
 
Java JVM
Java JVMJava JVM
Java JVM
 
Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...
Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...
Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...
 
A Brief study on JVM A Brief study on JVM
A Brief study on JVM A Brief study on JVMA Brief study on JVM A Brief study on JVM
A Brief study on JVM A Brief study on JVM
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunning
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunning
 
Java Virtual Machine - Internal Architecture
Java Virtual Machine - Internal ArchitectureJava Virtual Machine - Internal Architecture
Java Virtual Machine - Internal Architecture
 
JVM, JRE and Javac are the main part for the java program
 JVM, JRE and Javac are the main part for the java program JVM, JRE and Javac are the main part for the java program
JVM, JRE and Javac are the main part for the java program
 
Lecture 2 Java Virtual Machine .pptx
Lecture 2 Java Virtual Machine .pptxLecture 2 Java Virtual Machine .pptx
Lecture 2 Java Virtual Machine .pptx
 
Android Training Chandigarh
Android Training ChandigarhAndroid Training Chandigarh
Android Training Chandigarh
 
JAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptx
JAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptxJAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptx
JAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptx
 
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
 
Java JDK.docx
Java JDK.docxJava JDK.docx
Java JDK.docx
 
imperative programming language, java, android
imperative programming language, java, androidimperative programming language, java, android
imperative programming language, java, android
 
Understanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual MachineUnderstanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual Machine
 

Plus de Omar Bashir

Cloud migration challenges london ct os
Cloud migration challenges   london ct osCloud migration challenges   london ct os
Cloud migration challenges london ct osOmar Bashir
 
5 Software Development Lessons From a Mountaineer
5 Software Development Lessons From a Mountaineer5 Software Development Lessons From a Mountaineer
5 Software Development Lessons From a MountaineerOmar Bashir
 
Technology Agility
Technology AgilityTechnology Agility
Technology AgilityOmar Bashir
 
Quality Loopback
Quality LoopbackQuality Loopback
Quality LoopbackOmar Bashir
 
Achieving Technological Agility
Achieving Technological AgilityAchieving Technological Agility
Achieving Technological AgilityOmar Bashir
 
Technical Debt: Measured and Implied
Technical Debt: Measured and ImpliedTechnical Debt: Measured and Implied
Technical Debt: Measured and ImpliedOmar Bashir
 
Distilling Agile for Effective Execution
Distilling Agile for Effective ExecutionDistilling Agile for Effective Execution
Distilling Agile for Effective ExecutionOmar Bashir
 
Authorisation: Concepts and Implementation
Authorisation: Concepts and ImplementationAuthorisation: Concepts and Implementation
Authorisation: Concepts and ImplementationOmar Bashir
 
Coding for 11 Year Olds
Coding for 11 Year OldsCoding for 11 Year Olds
Coding for 11 Year OldsOmar Bashir
 
High Speed Networks - Applications in Finance
High Speed Networks - Applications in FinanceHigh Speed Networks - Applications in Finance
High Speed Networks - Applications in FinanceOmar Bashir
 
Functional Programming in Java 8
Functional Programming in Java 8Functional Programming in Java 8
Functional Programming in Java 8Omar Bashir
 
Computing at Schools: A Guide to Parents
Computing at Schools: A Guide to ParentsComputing at Schools: A Guide to Parents
Computing at Schools: A Guide to ParentsOmar Bashir
 
Information technology
Information technologyInformation technology
Information technologyOmar Bashir
 
Maths with Programming
Maths with ProgrammingMaths with Programming
Maths with ProgrammingOmar Bashir
 
Code Club Talk 2014
Code Club Talk 2014Code Club Talk 2014
Code Club Talk 2014Omar Bashir
 

Plus de Omar Bashir (17)

Cloud migration challenges london ct os
Cloud migration challenges   london ct osCloud migration challenges   london ct os
Cloud migration challenges london ct os
 
5 Software Development Lessons From a Mountaineer
5 Software Development Lessons From a Mountaineer5 Software Development Lessons From a Mountaineer
5 Software Development Lessons From a Mountaineer
 
Why Java ?
Why Java ?Why Java ?
Why Java ?
 
Technology Agility
Technology AgilityTechnology Agility
Technology Agility
 
Quality Loopback
Quality LoopbackQuality Loopback
Quality Loopback
 
Achieving Technological Agility
Achieving Technological AgilityAchieving Technological Agility
Achieving Technological Agility
 
Technical Debt: Measured and Implied
Technical Debt: Measured and ImpliedTechnical Debt: Measured and Implied
Technical Debt: Measured and Implied
 
Distilling Agile for Effective Execution
Distilling Agile for Effective ExecutionDistilling Agile for Effective Execution
Distilling Agile for Effective Execution
 
Authorisation: Concepts and Implementation
Authorisation: Concepts and ImplementationAuthorisation: Concepts and Implementation
Authorisation: Concepts and Implementation
 
SOLID Java Code
SOLID Java CodeSOLID Java Code
SOLID Java Code
 
Coding for 11 Year Olds
Coding for 11 Year OldsCoding for 11 Year Olds
Coding for 11 Year Olds
 
High Speed Networks - Applications in Finance
High Speed Networks - Applications in FinanceHigh Speed Networks - Applications in Finance
High Speed Networks - Applications in Finance
 
Functional Programming in Java 8
Functional Programming in Java 8Functional Programming in Java 8
Functional Programming in Java 8
 
Computing at Schools: A Guide to Parents
Computing at Schools: A Guide to ParentsComputing at Schools: A Guide to Parents
Computing at Schools: A Guide to Parents
 
Information technology
Information technologyInformation technology
Information technology
 
Maths with Programming
Maths with ProgrammingMaths with Programming
Maths with Programming
 
Code Club Talk 2014
Code Club Talk 2014Code Club Talk 2014
Code Club Talk 2014
 

Dernier

Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 

Dernier (20)

Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 

An Introduction to Java Compiler and Runtime

  • 1. Java Compiler and Runtime Omar Bashir @OmarBashir_40 obashir@yahoo.com
  • 2. Java: Write Once Run Anywhere Java Source Code (.java files)
  • 3. Java: Write Once Run Anywhere Java Source Code (.java files) Java Compiler
  • 4. Java: Write Once Run Anywhere Java Source Code (.java files) Java Compiler Java Bytecode (.class files)
  • 5. Java: Write Once Run Anywhere Java Source Code (.java files) Java Compiler Java Bytecode (.class files) Java Virtual Machine
  • 6. Java: Write Once Run Anywhere Java Source Code (.java files) Java Compiler Java Bytecode (.class files) Java Virtual Machine Interpreted platform specific instructions Any Hardware
  • 7. Java Virtual Machine (JVM) ● A virtual computer that executes Java bytecode. – A platform specific program giving Java its platform independence. ● Key JVM concepts, – Specification ● Abstract definition omitting irrelevant implementation details. – Implementation ● Platform specific implementation that executes bytecode. – Instance ● Each Java application is executed in a separate JVM instance. ● Launched by executing the java command.
  • 8. Java HotSpotTM Virtual Machine ● Oracle's/Sun's JVM implementation. ● Key features – JIT (Just In Time) compilation ● Compilation of specific program sections to native instructions and caching them. – Adaptive optimisation ● Dynamic recompilation of program sections based on current execution profiles. ● Generational garbage collection – Disposing unused objects and reclaiming memory.
  • 9. JVM Architecture Class Loader Compiled Classes JVM Runtime Memory Heap Method Area Java Stack Native Method Stack Program Counter Registers Execution Engine Native Interface Native Libraries Thread common memory Thread specific memory Code Cache
  • 10. JVM Architecture Thread common memory Thread specific memoryThread common memory Dynamic on demand loading of Java classes from the classpath 1. Loading bytecode, 2. Linking, 3. Variable initialisation Class Loader Compiled Classes JVM Runtime Memory Heap Method Area Java Stack Native Method Stack Program Counter Registers Execution Engine Native Interface Native Libraries Code Cache
  • 11. JVM Architecture Thread common memory Thread specific memory Heap contains instances of classes, i.e., objects. Heap is garbage collected to remove unused objects. Class Loader Compiled Classes JVM Runtime Memory Heap Method Area Java Stack Native Method Stack Program Counter Registers Execution Engine Native Interface Native Libraries Code Cache
  • 12. JVM Architecture Thread common memory Thread specific memory Method Area stores information regarding loaded classes, their fields, methods and values of class variables. Also referred to as Perm Gen, it no longer exists in Java 8. Class Loader Compiled Classes JVM Runtime Memory Heap Method Area Java Stack Native Method Stack Program Counter Registers Execution Engine Native Interface Native Libraries Code Cache
  • 13. JVM Architecture Thread common memory Thread specific memory Code cache stores methods that have been compiled to native code. Class Loader Compiled Classes JVM Runtime Memory Heap Method Area Java Stack Native Method Stack Program Counter Registers Execution Engine Native Interface Native Libraries Code Cache
  • 14. JVM Architecture Thread common memory Thread specific memory Stacks are per thread memory frames organised in LIFO (Last In First Out) structure. Class Loader Compiled Classes JVM Runtime Memory Heap Method Area Java Stack Native Method Stack Program Counter Registers Execution Engine Native Interface Native Libraries Code Cache
  • 15. JVM Architecture Thread common memory Thread specific memory Program counter and three registers manage the stack. Stack-oriented design helps keep the JVM's instruction set and implementation small. Program counter tracks instructions to be executed. optop register points to the top of operand stack, the workspace. frame register points to operations of the stack. vars register points to the local variables sections. Class Loader Compiled Classes JVM Runtime Memory Heap Method Area Java Stack Native Method Stack Program Counter Registers Execution Engine Native Interface Native Libraries Code Cache
  • 16. JRE Java Runtime Environment (JRE) JVM Java Class Library Package needed to run a Java application
  • 17. JDK Java Development Kit (JDK) JRE JVM Java Class Library Java Development Tools
  • 18. javac – Java Compiler ● Part of JDK ● Reads Java class and interface files and compiles them into bytecode class files. – Source files have .java extensions. – Bytecode files have .class extensions. ● Syntax – javac [options] [sources] [classes] [@argfiles] ● options: Command line options. ● sources: Source files. ● classes: Classes to be processed for annotations. ● argfiles: Files listing options and source files.
  • 19. javac – Java Compiler ● Most frequently used options, – -cp: Classpath, i.e., path to dependencies. – -d: directory containing the compiled classes. – -deprecation: Shows a description of each use of a deprecated member or class. – -g: Generate debugging information.
  • 20. javac – Java Compiler (Example) code bin src app calc CalcApp.java Calculator.java javac src/*/*.java ­d bin 
  • 21. javac – Java Compiler (Example) code bin src app calc CalcApp.java Calculator.java app calc CalcApp.class Calculator.class
  • 22. java – Launch Java Application in JVM ● Syntax – java [options] main-class [arguments …] – java [options] -jar file.jar [arguments …] ● Most frequently used options, – -cp: Classpath, path to libraries and class files. – -Dproperty=value: set a system property. – -Xmsn: Minimum heap size. – -Xmxn: Maximum heap size. – -Xssn: Stack size.
  • 24. jar – Java Archive ● Grouping class files into libraries and java executables. – Convenient packaging and deployment. – Based on the zip file format. – Command syntax closely related to tar ● Syntax – Creation, ● jar cf jarfile input-files ● jar cmf manifest jarfile input-files – Extraction ● jar xf jarfile ● Manifests provide, – Versioning, signing, specifying classpaths, java executable.
  • 26. Garbage Collection ● JVM relieves coders from deleting unused objects. ● Unused objects are deleted from the heap by the Garbage Collector (GC). – i.e., objects whose reference is not assigned to any variable. ● Each application has two threads at least, – Thread running main, – Thread running GC. ● When the GC thread runs, all other threads may pause (Dependant on GC implementation). – GC's execution is non-deterministic. – Results in Java not being suitable for applications with strict timing constraints (i.e., real-time applications).
  • 28. Garbage Collection ● Young generation – New objects created. – Minor garbage collection removes dead objects. – Surviving objects aged and moved to old generation. ● Old generation – Long surviving objects. – Major garbage collection removes dead objects. ● Permanent generation – Metadata of methods and classes for the JVM Eden S0 S1Eden Tenured Permanent Young Generation Survivor Space Old Generation Permanent Generation