This article is giving short yet complete information about Java Virtual Machine. Java Virtual Machine is also known as JVM.
Java Virtual Machine
The Java Virtual Machine is a software package that comes with the JRE or JDK. It is a virtual machine which is responsible for running the byte code. The byte code is compiled Java classes of an application. The JVM is responsible for compiling the the byte code for the machine on which JVM is running and then finally executing the program.
The JVM is heart of Java Platform and runs the Java program on an Operating System. The JVM is OS specific and is different for each OS. For example JVM for Windows won't run on Linux and vice versa.
JVM - Execution Environment
JVM or Java Virtual Machine provides the execution environment for the Java programs. It is also known as Java Runtime Environment or JRE.
Java program must be compiled into byte code .class file before running it on the JVM. JVM reads the byte code and then compiles it to the machine specific code and then runs.
Steps for writing and testing the program:
Step 1: Write Java code in a text file save it with the .java extension.
Step 2: Compile the .java file into byte code (.class) file
Step 3: Run the file using JVM
Features of JVM
- JVM compiles the byte code into platform specific code. JVM makes your program platform independent.
- A virtual machine: JVM is an implementation of a machine e.g. a computer.
- Garbage Collection: JVM is responsible for cleaning up the memory space. So, programmer don't worry about cleaning the memory. JVM automatically garbage collect and frees the memory.
- JVM provides platform independence by defining the primitive data types.
- JVM achieves the platform independence by using the network byte order in Java class files
So, JVM is very important part of Java platform. Read more tutorials at Java Tutorial section.