Java virtual machine

25

Transcript of Java virtual machine

Page 1: Java virtual machine
Page 2: Java virtual machine

Sanooja Jabbar [email protected]/sanooja jabbartwitter.com/usernamein.linkedin.com/in/profilename+91-9895519936Typing Speed: 34wpm

Page 3: Java virtual machine

Disclaimer: This presentation is prepared by trainees ofbaabtra as a part of mentoring program. This is not officialdocument of baabtra –Mentoring PartnerBaabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd

Page 4: Java virtual machine

Virtual Machine

“A virtual machine is a layer of abstraction that gives a

program, one simplified interface for interacting with a

variety of physical computers and their operating systems.”

Page 5: Java virtual machine

Java Virtual Machine

• JVM is not a real hardware machine but a software layer which resembles

an hardware platform.

• JVM converts Java byte code into machine language and executes it.

• The byte code can be executed on any platform where there exist JVM.

• JVM‘s are available for many hardware and software platforms.

• The use of the same byte code for all JVM’s on all platforms allows Java to

be described as a "write once, run anywhere" programming language.

• Thus, the JVM is a crucial component of the Java platform.

Page 6: Java virtual machine

Diagram Of JVM

Java Source

Code(.java)

Java Object

Code(.class)

Java Compiler (javac)

Computer Operating System

Java Interpreter

Java Virtual Machine

Object Code is loaded intoJava Virtual Machine

Page 7: Java virtual machine

Components Of JVM

Class Loader Execution Engine

Run-time data areas

Java Virtual Machine

.class file

Page 8: Java virtual machine

Components Of JVM

1. Byte code verifier

2. Class loader

3. Execution engine

4. Garbage collector

5. Security Manager

Page 9: Java virtual machine

1. Byte code Verifier:

• Byte code verifier is used to verify the byte code.

• Also checks for unusual code.

• So it is a crucial component for security.

2. Class loader:

• Class loader loads java classes into java virtual machine and creates

the instance of java.lang.class.

• The main feature is that JVM doesn’t need to have any knowledge

about the classes that will be loaded at runtime.

• It performs three main functions of JVM, namely: loading, linking

and initialization

Page 10: Java virtual machine

3. Execution Engine:

• The execution engine helps JVM to convert bytecode into machine code.

• It has two parts:

a) Interpreter

b) Just-in-time-interpreter

• Execution engine is responsible for executing the instructions contained in

the methods of loaded classes.

4. Garbage Collector:

• Garbage collection is the process of automatically freeing objects that are

no longer referenced by the program.

• It periodically check for the object on heap , whose link is broken so it can

collect garbage from heap.

• Garbage collection relieves java programmer from memory management.

Page 11: Java virtual machine

5. Security Manager:

• Security manager constantly monitors the code.

• It is a special java object that is responsible for guarding security policies

for java applications.

• It is always consulted before any potentially dangerous operation is

requested by a java application.

Page 12: Java virtual machine

JDK ‘n’ JREDiagram to show the relations between JVM, JRE & JDK

Page 13: Java virtual machine

Java Runtime Environment(JRE):

• Provides the libraries, the Java Virtual Machine, and other components to

run applets and applications written in the Java programming language.

• The JRE does not contain tools and utilities such as compilers or

debuggers for developing applets and applications.

Java Development Kit(JDK):

• JDK is a bundle of software that is used to develop Java based

applications.

• The JDK is a superset of the JRE, and contains everything that is in the

JRE, plus set of API classes, Java compiler and debugger, and additional

files needed to write Java applets and applications.

• Needs more disk space than JRE

Page 14: Java virtual machine

Just In Time(JIT):

• JIT are advanced part of Java Virtual machine

• It optimize byte code to machine instruction conversion by compiling

similar byte codes at same time

• Thus reducing overall execution time.

• JIT performs several optimizations such as in-lining function.

• JIT compiler improves performance

Page 15: Java virtual machine

In Short....

• Java Virtual Machine (JVM) is platform dependent.

• Java is platform independent.

• JVM does not really exists but is created within another environment.

• The JVM stands on top of the operating system (OS).

Page 16: Java virtual machine

Is

Java a

Compiled or InterpretedLanguage

Page 17: Java virtual machine

Java is both compiled and interpreted

language.

Java compiles using javac and JIT, and

interprets using Java virtual machine.

Page 18: Java virtual machine

“From Writing to

Execution”

Page 19: Java virtual machine

1

2

“Programmer write source code and store thatinto a .java file.”Note: Name of your Java source file must be same with the public class declared inside that file, for example if there is public class called Order inside Java file, then it name must be Order.java

“javac compiles .java fie and creates class files, which contains byte code”

Page 20: Java virtual machine

3

4

“JVM executes these class files and gathers statistics of execution run.”

“When JVM has enough data to make decision, JIT compiles frequently used byte codes into native code, which is then directly executed by platform. This is how JIT provides performance boost to Java application.”

Page 21: Java virtual machine

Any Doubts...???

Page 22: Java virtual machine

Thanks For

Listening...

The End

Page 23: Java virtual machine

Want to learn more about programming or Looking to become a good programmer?

Are you wasting time on searching so many contents online?

Do you want to learn things quickly?

Tired of spending huge amount of money to become a Software professional?

Do an online course @ baabtra.com

We put industry standards to practice. Our structured, activity based courses are so designedto make a quick, good software professional out of anybody who holds a passion for coding.

Page 24: Java virtual machine

Follow us @ twitter.com/baabtra

Like us @ facebook.com/baabtra

Subscribe to us @ youtube.com/baabtra

Become a follower @ slideshare.net/BaabtraMentoringPartner

Connect to us @ in.linkedin.com/in/baabtra

Thanks in advance.

www.baabtra.com | www.massbaab.com |www.baabte.com

Page 25: Java virtual machine

Contact Us

Emarald Mall (Big Bazar Building)Mavoor Road, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550

NC Complex, Near Bus StandMukkam, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550

Cafit Square,Hilite Business Park,Near Pantheerankavu,Kozhikode

Start up VillageEranakulam,Kerala, India.

Email: [email protected]