Java Architecture
Java architecture is a combination of three parts they are JVM, JRE and JDK. These components will help in the functioning of the java programs. The process of code interpretation and compilation can be done with these components. Java Architecture describes the step-by-step execution and compilation of the code by the java compJava compiler step-by-step execution and compilation.

The following steps can describe Java Architecture:
- Java has both compilation and interpretation processes.
- The compiler in java will convert the written java code to byte code.
- After converting to byte code, the component( JVM) will convert it to machine code.
- After that, the converted machine code is executed using the machine.
Now let us discuss the components in detail.
Components of Java Architecture
- Java Virtual Machine (JVM)
- Java Runtime Environment (JRE)
- Java Development Kit (JDK)

Java Virtual Machine
Java Virtual machine main feature WORA. Write Once Run Anywhere. This feature describes that you write the code at once and can use the program it any platform or on any platform. What can run the programs written in java on any of the platforms due to the availability of the Java Virtual Machine? Java Virtual Machine will act as a platform for executing java programs. The foremost task of this machine is to convert byte code to machine code. Firstly it will load the code and verifies it in the memory. After loading the code into memory and it executes the code. JVM can be available for any platform because it is platform-independent.
1. It will specify the working of the JVM. Oracle and many other companies can provide the implementation.
2. Implementation can be done by JRE (Java Runtime Environment)
3. The runtime instance in this code is written on a command prompt to run java code.
The operations which JVM performs are:
- Loading the class
- Verifying the code
- Executing the code
- Provided the runtime environment
JVM Contains:
- Memory
- Class file
- Registering the set
- Garbage collection heap
It contains the classloader, memory area, and execution engine.
1) Classloader
This system is a subsystem of JVM for loading files. When the java program was running, it loaded in the class loader. There are three classloaders in java.
->Bootstrap ClassLoader: This is the superclass of the Extension. In this class rt.jar
file is in java.lang package, java.io, and java.sql packages.
->Extension ClassLoader: This is the base class of the classloader of Bootstrap and the parent class of the System classloader. The jar files are loaded inside the $JAVA_HOME/.
JRE/lib/ext directory.
->Application classLoader: It is the base classloader for the extension class loader. The files loaded in the classpath. Classloader will set it in the classpath. The class can be changed by using the command “ -cp”. As it will switch the application, it is called an Application classloader.
//Program
//Example, for printing the class loader
public class loader
{
public static void main(String[] args)
{
// printing the class loader for the current class
//classloader will load the class
Class c=CLoader.class;
System.out.println(c.getClassLoader());
//the result will be printed as null because it is a builtin class it can be founded in
// rt.jar
System.out.println(String.class.getClassLoader());
}
}
Output:

2) class Area
This method will store the per-class structures for storing the runtime pool and the code for storing the methods.
3) Heap
The Heap area is used for storing the objects.
4) Stack
The stack area is used for storing frames. The stack area will store the local variables and methods. Threads are created in the stack area for each new thread creation. When the method invocates, it will destroy the frame.
5) PC Register
It is a program counter register containing the address of the JVM that is currently executed.
6) Native Method Stack
can store the native methods used in the application in the Native Method stack.
7) Execution Engine
The execution engine will work as a virtual processor. It contains an Interpreter for reading the byte code, and then the instructions are executed. JIT is a Just-in-Time compiler used for performance improvement. This compiler will compile the code with similar functionality and reduce compile time. The compiler will transform instructions from JVM to CPU instructions set.
8) Java Native Interface
This interface is a framework which provides a platform to relate programs from different languages (C, C++) to their applications. It is used to get the console output and interact with the operating system libraries.
Java Runtime Environment
It will create an environment for the execution of the program. The process works; the code is first loaded and integrated with the libraries required, and after this process starts, JVM for running the code. Java Runtime Environment is the Java Development kit(JDK) subgroup. It contains the class libraries and stand-alone JVM. It is one most available environments for executing java programs. Using the JRE, the written code is converted to byte code for executing the byte code JRE required in any platform. JRE will be on top of most of the operating systems.
It contains:
- Java web start can be done using JRE
- Interfaces toolkits ex: java 2D
- It contains the libraries for connecting the Database(JDBC).
- Predefined libraries such as lang and util.
- It also includes some libraries like Java Management Extensions (JMX) and java processing libraries.
What does JRE contain?
The components of JRE are:
- Deployment technologies the technologies are deployment, plug-in etc.
- Interface toolkits are for designing applications interfaces, such as Abstract Window Toolkit(AWT), Swings, Applet, Sound and input methods.
- Libraries Java Data Base Connectivity(JDBC), Java Naming And Directory Interface(JNDI), Remote Method Invocation(RMI).
- Other libraries include I/O input and output, extension mechanisms, Net Beans, Java Native Interface(JNI), Math module, Overriding mechanism, Serialization method and XML processing in java.
- Base libraries include the lang, util, Zip files, Java Archive (JAR) files, Collections, API performances, and Re Expressions(Regular Expressions).
- Java Virtual Machine will act like a server connecting the Server to the Virtual Machine and client.
Working of JRE with the JVM

JRE contains Java Virtual Machine inside it, Library classes, and Development tools.
We can understand the working of JRE with the help of the below program.
//Program
import java.util.*
public static void main(String[] args){
System. out.println(?Hi Everyone?);
}
After completing the program's writing, you can save the program with the .java extension. After saving the program with the java extension, it will be compiled using the javac filename.java. The result is Bytecode, independent of the platform, so it can run in any JRE software. From this, the work of JRE begins. The following diagram describes the flow of byte code:

The steps which are taken at runtime:
- Class loader
In this step, the class loader will load the required classes for running the code. It will load dynamically from JVM. The class loader which is used are:
1. Bootstrap class loader
2. Extensions class loader
3. System class loader
- Byte code verifier
It will work as security checking the Bytecode to reduce disturbance for an interpreter. Can do the interpretation of code only once.
- Interpreter
An interpreter will read the code line by line by following the functions:
Execution of the byte code.
Making calls to hardware.
In the above process, can exe can execute the program in JRE.
Java Development Kit (JDK)
The Java Development kit is an environment to develop software applications and dynamic web pages(Applet). JDK contains JRE and the development tools. Any of the below java platforms can implement JDK by Oracle corporation:
- Standard Edition
- Enterprise Edition
- Micro Edition
JDK contains virtual machines and others like interpreter java, compiler javac, and archiver jar for developing java Applications. There are different kinds of components available in JDK:
Applet viewer: | Without having any web browser, the running and debugging of applets can be done by this. |
Apt: | It is used for processing. |
Next check: | It is used for the detection of conflicts. |
Java: | The development and deployment process can be done with a single launcher. Java is used for loading the applications. It is an interpreter which generates class files. |
Jmc: | It is the mission controller |
Jps: | It is a java virtual machine process status tool used to instrument the virtual machine's hotspot. |
Policy tool: | It will create a policies management tool, which is used in determining runtime and other sources. |
Wsimport: | It is used for invoking web services. |
keytool: | The use of this tool is for keystores manipulation |
Transcript | It is a command line script |
Javainfo | This component's utility is getting the information from the java machine. |