JAVA VIRTUAL MACHINE (JVM)
THE JAVA VIRTUAL MACHINE (JVM)
THE JAVA VIRTUAL MACHINE (JVM) plays an important role in making the JAVA language portable and platform independent as it hides the details of implementation between the hardware requirement and the operating system. JAVA VIRTUAL MACHINE runs the compiled java program and provides compatibility between the compiled java program and the system , where the program is executed.
Java program are compiled into class files using the executable file, javac. A java complier generates the bytecode and loads it in JAVA VIRTUAL MACHINE using JAVA VIRTUAL MACHINE class loaders. The JAVA VIRTUAL MACHINE class loaders load the class files and execute the bytecode in accordance with the operating system and the hardware configuration. JAVA VIRTUAL MACHINE allows you to execute a Java program on any operating system such as UNIX system , Windows system or Macintosh system . figure shows the process of compilation and execution of a Java program.
The JAVA interpreter executes the byte codes that are generated by a Java compiler and converts the byte codes into machine-readable code . figure shows the process converting the byte code into a machine code.
The class loaders in JAVA VIRTUAL MACHINE memory to the loaded JAVA class files. Class loaders also provide mobility to Java program as these class loader allow source code to be dynamically linked across the network. Class loaders also provide network security to the Java program.
The class loaders in JAVA VIRTUAL MACHINE are of two types : primordial class loader and Java class loader. The primordial class loader the Java Application Programming Interface (API) at the time of executing a java program. You can instantiate multiple class loader during run-time to load the class files are class files.
A Java program interacts with the host operating system by invoking the native method while executing program on JAVA VIRTUAL MACHINE. The two ways by which you can invokes native methods are Java method and Native method. Figure show the block diagram of he java Virtual Machine.
The native methods are written in a non- Java program language such as C++ or assembly language and are compiled into the native machine code. The native methods are platform-dependent and are stored in Dynamic Linked Libraries (DLLs).