The Java Virtual Machine (JVM) executes the Java programs bytecode (.class file). The bytecode is generated after the compilation of the program by the Java compiler.
Java Virtual Machine (JVM)
The Java Language is designed so that the Java program can be "written once, and run anywhere?. Java has the ability to run the same program on many different hardware configurations and operating systems. The JVM makes the Java as a portable and platform independent language. Java Virtual Machine Works behind this concept. The Java Virtual Machine (JVM) executes the Java programs bytecode (.class file). The bytecode is generated after the compilation of the program by the Java compiler. The Java Virtual Machine is the software program and data structures that is on the top of the hardware. The Java virtual machine is called "virtual" because it is an abstract computer (that runs compiled programs) defined by a specification. The Java Virtual Machine is the abstraction between the compiled Java program and used hardware and operating system. The Java Virtual Machine's (JVM) function is to load the appropriate class files for executing a Java Program, and then to execute it. The JVM for different systems is not same i.e. they are alike.
The working of the JVM is shown by the figure as follows:
The Java language is used bytecode. The bytecode is a special type of code that run only on the JVM. The Java Virtual Machine is responsible for handling the bytecode and translate it in to actual Machine code. The bytecode is platform independent and the machine code is platform dependent. JVM forms the Java Runtime Environment (JRE) for the program execution. Each operating system and CPU architecture requires a different JRE. The JRE comprises a set of base classes, which are an implementation of the base Java API, as well as a JVM. The role of the JVM started when program is compiled. when the the program is compiled then JVM interpret the byte code in to the Machine code and then create actions and tasks and generates output.