Previously we had begin with Java Tutorial beginners guide featuring – What is Java , features of Java Programming Language , Java editors and different Java editions and Java Application Types . Now on Java tutorial we begin with the section 2 that is about JVM – Java Virtual Machine . And also about the difference between JDK Vs JRE Vs JVM including other aspects of Java Virtual Machine .
Guys, to deep dive in java, let’s have a look how it works internally..
Java Virtual Machine Windows 7
A role of Java virtual machine (short form as JVM) is to execute Java bytecode. We can state that JVM is the component of the Java software platform where code execution happens. Right now over 5.5 billion computer are in the market which are JVM-enabled. JVM lives inside our PC/computer and byte code is the language for JVM. With the introduction of JVM, job of compiler becomes very easy as it only generate byte code for JVM rather than generating different machine code for each m/c which is the reason why java language is platform independent.
A JVM executes programs containing Java bytecode instructions and are generally implemented to run on existing operating system (windows etc). A JVM provides a run-time environment which enables features such as exception handling which in turns provides debugging capability for every software exception. A JVM is a part of Java Class Library (some inbuilt java classes in the form of bytecode) to provide basic functions to developer while doing coding in Java. These libraries with the JVM together named as Java Runtime Environment (JRE).
Update Java Virtual Machine Mac
JVMs are compatible and available for almost all hardware and software platforms. Due to this feature of using the same bytecode for all JVMs on all platforms makes Java to be known as a write once and run anywhere language. This clearly describe that JVM is a crucial component of the Java language. Java bytecode is an machine language which is typically compiled from Java (or from other programming languages).
HotSpot is the most used JVM which is written in the C++ programming language. JVM doesn’t understand Java code due to which we require java compiler that compiles source code and create .class file. This .class file is composed of byte code which JVM can understand. There are two main components of JVM – heap memory and garbage collector. We will discuss about both in detail in the upcoming discussion.
Contents
The JVM can run this same bytecode on any machine that supports the JVM because the Java Virtual Machine is aware of the particularities on the low level of each machine type. Now, in order for the Java virtual Machine to work, it has to be run on a given platform, think Mac or windows, according to the Java Virtual Machine specification. Download and install the latest Java Virtual Machine in Internet Explorer. Go to www.java.com. Click Free Java Download. Click Agree and Start Free Download.
- 2 JVM Vs JRE Vs JDK
How JVM works
Now moving on with the Java tutorial section , we will see working of Java Virtual machine ie, how JVM works exactly.
Look at the pictorial format that explains the working of JVM.
- After reading .class file, class loader save the corresponding byte code in the method area. Generally all JVMs have only one method area which is shared across classes which holds information related to each .class file.
- Heap is an integral part of JVM memory in which the objects actually rests. JVM produces the Class object for each .class file.
- Unlike Heap, Stack is used for storing temporary variables.
- PC-Registers used to keep exact information of all instructions (which instruction is executing and which is going to be executed).
- A native method used to access the runtime data of the JVM (java virtual machine). Native Method interface enables java code to call by the native applications (programs that are specific to the hardware and OS).
- We will cover Garbage collection in the upcoming article
JVM Vs JRE Vs JDK
Now let’s sort out the difference between JVM ,JRE and JDK . How does these differ from each other – JVM Vs JRE Vs JDK .
JRE ( Java Runtime Environment )
Java Runtime Environment is within which the java virtual machine actually runs. JRE contains Java virtual Machine and other files except development tools (debugger and compiler). So developer can run the source code in JRE but he/she cannot develop and compile the code.
JVM ( Java Virtual Machine )
Java Virtual Machine Download For Windows 10
As per above discussion, JVM runs the program by using libraries and files provided by Java Runtime Environment.
JDK ( Java Development Kit )
Java Development Kit can be considered as the super-set of JRE. JDK includes all features that JRE has and over and above it contains development tools such like compiler, debugger etc.
Now we have discussed about what is JVM ( Java Virtual Machine ) and how JVM works . Also in depth we have discussed about the difference between JVM Vs JRE Vs JDK.
On the third session of Java Programming Tutorials we will discuss about the Java Basic Syntax and Java Environment Setup .