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..
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).
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.
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.
Now let’s sort out the difference between JVM ,JRE and JDK . How does these differ from each other – JVM Vs JRE Vs JDK .
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.
As per above discussion, JVM runs the program by using libraries and files provided by Java Runtime Environment.
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 .
0 comments