Check full java topics on this main page
Like other programming languages, Java has its architecture. Below are the components of this architecture
JVM - Java Virtual Machine
JRE - Java Runtime Environment
JDK - Java Development Kit
Representation of architecture components
Let's cover JVM, JRE, and JDK in detail
1. Java Virtual Machine(JVM)
- This is the main component of Java architecture. This makes the statement WORA(Write Once Run Anywhere) possible
- Input for JVM is .class file generated after compiling the program
- .class file is also called byte code
- Along with JRE, JVM converts byte code into machine code
Key components of JVM
JIT Compiler
- It is an intermediate component of compiler and interpreter
- This converts the byte code into native machine code.
- This is used for performance optimization
Interpreter
- This reads line by line of byte code and converts into native machine code
Working of Java Virtual Machine(JVM)(Basic)
- JRE provides the environment for byte code to get executed in JVM
- JRE contains libraries that help to run a java program
Class Loader:-
- Classloader loads all classes and saves in the different classpath
- Classloader follows Delegation Hierarchy Principle (Classes are searched by this order Application class loader -> Extension class loader -> Bootstrap class loader)
- When JVM made a request for a specific class first it will ask the Application class loader to provide required class details(Searches in application classpath). Then Application class loader asks the extension class loader to provide class details(Searches in Extension classpath). If the details are not there in this loader it will ask the Bootstrap class loader to provide the details(Searches in Bootstrap classpath). If the class is not in any of the class loaders, it will throw java.lang.ClassNotFoundException.
Byte code Verifier:-
- The byte code verifier checks all the instructions from the classloader. Then if the code has no violation of any rules it will be passed to JVM. If it fount any error in this phase it will throw an exception.
- It will check variables, method calls, private data, and private methods
3. Java Development Kit(JDK)
Compiler in Java(JAVAC)
The purpose of this compiler is to convert .java file into .class file or byte code. This byte code file(.class file) contains some form of representations. By using this byte code and JRE we can able to get output for our program on any platform.
Hope this post gave you a basic understanding of java architecture. Below are the summarised steps- A java program was created(.java file)
- Once the program starts running, it enters the compiler(JDK component) and creates byte code(.class file)
- This byte code is passed to JRE
- classloader loads all the classes from the program in different types of classloaders
- Once JVM gave a request for a specific class, the classloader provides the class details. In between these byte code verifier verifies the code for violation rules
- In JVM it interprets the code to native code
- With the user of native code, the microprocessor does the task provided from our source file.
Hope this will be helpful and valuable for your time
Feel free to post your queries!!
Next Overview of Java
Comments
Post a Comment