We have seen that Java programming language finds its various applications in different working fields in world of computers and technology. In this post I’ll tell you about the basic architectural features of Java in brief.
The Java Virtual Machine (JVM):
JVM is defined as: “An imaginary machine that is implemented by emulating it in software on a real machine.” The code for the JVM is stored in the .class files, each of which contains the code on the public class.
The compiler takes the Java application source code and generates bytecodes. Bytecodes are machine code instructions for the JVM. Every Java interpreter, regardless whether it is JAVA technology development tool or a web browser that can run applets, has an implementation of the JVM. The JVM design allows the creation of implementation for multiple operating environments.
Garbage collection:
Many programming languages allow the dynamic memory allocation. The process varies according to the syntax of the programming language, but always involves the returning of a pointer to the starting address of the memory block. After the allocated memory is no longer required the program or the run-time environment should de-allocate the memory.
In C, C++ and other languages, you are responsible for de-allocating the memory. This can be difficult exercise sometimes because you do not know which memory to de-allocated in advance. Programs that donot de-allocate the memory eventually crash.
However Java programming language removes you from the responsibility of de-allocating the memory. It provides a system level thread that tracks ach memory allocation. During idle cycles in the JVM the garbage collection thread checks for and frees the memory that can be freed.
The Java Runtime Environment:
Java software source files are compiled in the sense that they are converted to a set of byte codes. These byte codes are then saved in ‘.class’ files. At the run time the bytecodes that make up a Java program are loaded, checked and run in an interpreter. The interpreted has two functions: it executes bytecode and makes the necessary calls.
JVM tasks:
The following are the tasks performed by the JVM:
- Loading of class: This is done by the class loader.
- Verifying the code: It is performed by the bytecode verifier.
- Execution of the code: It is performed by the Runtime interpreter.
1. The Class Loader: The class loader loads all the classes that are required for the execution of the program.
2.The Bytecode Verifier: The JVM puts the code through the bytecode verifier that tests the format of the code fragments and checks the code fragments for illegal code, which is that forges illegal pointers , violates access rights on object or attempts to change object types.
3. The Verifying process: The bytecode verifier passes the code through four processes which verify whether the code adheres to the specifications mentioned by the JVM.