• This topic clears your questions like Explain jvm architecture in java  , jvm architecture in java with diagram, how JVM works internally and areas of Java Virtual Machine.
  • Virtual machine : In general terms Virtual machine is a software that creates an environment between the computer and end user in which end user can operate programs.
  • As per functionality Virtual machine is creation of number of different identical execution environments on a single computer to execute programs is called Virtual machine.
  • Java Virtual machine: it is also Virtual machine that runs java bytecode  by creating five identical run time areas to execute class members.


Function of java virtual machine

  • The bytecode is generated by java compiler in a JVM understandable format.
  • As a programmer we develop a java application and when we compile a java program, the compiler will generate .class (dot class) file.
  • The .class file contains byte code (Special java instructions).
  • To execute a java program we take the help of JVM (java virtual machine) to the JVM we have to provide .class file as the input.

Types of JVMs:

  • The java 2 SDK , Standard Edition , contains two implementation of the java virtual machine 
  1. Java HotSpot Client VM
  2. Java Hotspot Server VM

Java HotSpot Client VM:

  • The Hotspot Client VM is the default virtual machine of the java 2 SDK and java 2 run time environment .
  • As its name implies, it is tuned for best performance when running applications in a client environment by reducing application start up time and memory footprint.  

Java HotSpot Server VM:

  • The java HotSpot server VM is designed for maximum program execution speed for applications running in a server environment.
  • The Java HotSpot Server VM is invoked by using the server command line option when an application , as in java server MyApp.
  • Some of the features java HotSpot technology , common to both VM implementations, are the following.

Adaptive compiler:

  • Applications are launched using a standard interpreter, but the code is then analyzed as it runes to detect performance bottlenecks, or "hot spots".
  • The Java HotSpot VMs compile those performance critical portions of the code for a boost in performance , while avoiding unnecessary compilation of seldom used code.
  • The Java HotSpot VMs also uses the adoptive compiler to decide on the fly , how best to optimize compiled code with techniques such as in lining.
  • The run time analysis performed by the compiler allows it to eliminate guesswork in determining which optimizations will yield the largest performance benefit.

Rapid memory allocation garbage collection:

  • Java HotSpot technology provides for rapid memory allocation for objects , and it has a fast, efficient, state-of-the-art  garbage collector. 

Thread Synchronization:

  • The Java programming language allows for use of multiple , concurrent paths of program execution (called threads).
  • Java HotSpot technology provides a thread- handling capability that is designed to scale readily for use in large , shared memory multiprocessor servers.

Jvm architecture in java with diagram


JVM Architecture



Class Loader Sub System:     

  • The class loader sub system will take a .class file as the input and performance the following operations. 
  • The class loader sub system is responsible for loading the .class file (Byte code) into the JVM.
  • Before loading the Byte code into the JVM it will verify where there the Byte code is valid      or   not. This verification will be done by Byte code verifier.
  • If the Byte code is valid then the memory for the Byte code will be allocated in different areas.
  • The different areas into which the Byte code is loaded are called as Run Time Data Areas. The various run time data areas are.



1.Method Area: 

  • Java Virtual Machine Method Area can be used for storing all the class code and method code.
  • All classes bytecode is loaded and stored in this run time area , and all static variables are created in this area.

2.Heap Memory:

  • JVM Heap Area can be used for storing all the objects that are created.
  • It is the main memory of JVM , all objects of classes :- non static variables memory are created in this run time area.
  • This runtime  area memory is finite memory.
  • This area can be configured at the time of setting up of runtime environment using non standard option like
  • java -xms <size> class-name.
  • This can be expandable by its own , depending on the object creation.
  • Method area and Heap area both are sharable memory areas.

3.Java Stack area:

  • JVM stack Area can be used for storing the information of the methods. That is under execution. The java stack can be considered as the combination of stack frames where every frame will contain the stat of a single method.
  • In this runtime area all Java methods are executed.
  • In this runtime JVM by default creates two threads. they are
  • 1.main method
  • 2.Garbage Collection Thread
  •  main thread responsible to execute java methods starts with main method.
  • Also responsible to create objects in heap area if its finds new keyword in any method logic.
  • Garbage collection thread is responsible to destroy all unused objects from heap area.

4.PC Register (program counter) area:

  • The PC Register i Java Virtual Machine will contain address of the next instruction that have to be executed.

5.Java Native Stack:   

  • Java native stack area is used for storing non-java coding available in the application. The non-java code is called as native code.

  

Execution Engine:

  • The Execution Engine of JVM is Responsible for executing the program and it contains two parts.
  1. Interpreter.
  2. JIT Compiler (just in time compiler).
  • The java code will be executed by both interpreter and JIT compiler simultaneously which will reduce the execution time and them by providing high performance. The code that is executed by JIT compiler is called as HOTSPOTS (company).
  

Java programming interview questions

  1. Java Program to Print prime numbers? 
  2. What happens if we place return statement in try catch blocks 
  3. Write a java program to convert binary to decimal 
  4. Java Program to convert Decimal to Binary
  5. Java program to restrict a class from creating not more than three objects
  6. Java basic interview programs on this keyword 
  7. Interfaces allows constructors? 
  8. Can we create static constructor in java 
  9. Super keyword interview questions java 
  10. Java interview questions on final keyword
  11. Can we create private constructor in java
  12. Java Program Find Second highest number in an integer array 
  13. Java interview programming questions on interfaces 
  14. Top 15 abstract class interview questions  
  15. Java interview Questions on main() method  
  16. Top 20 collection framework interview Questions
  17. Java Interview Program to find smallest and second smallest number in an array 
  18. Java Coding Interview programming Questions : Java Test on HashMap  
  19. Explain java data types with example programs 
  20. Constructor chaining in java with example programs 
  21. Swap two numbers without using third variable in java 
  22. Find sum of digits in java 
  23. How to create immutable class in java 
  24. AtomicInteger in java 
  25. Check Even or Odd without using modulus and division  
  26. String Reverse Without using String API 
  27. Find Biggest substring in between specified character
  28. Check string is palindrome or not?
  29. Reverse a number in java?
  30. Fibonacci series with Recursive?
  31. Fibonacci series without using Recursive?
  32. Sort the String using string API?
  33. Sort the String without using String API?
  34. what is the difference between method overloading and method overriding?
  35. How to find largest element in an array with index and value ?
  36. Sort integer array using bubble sort in java?
  37. Object Cloning in java example?
  38. Method Overriding in java?
  39. Program for create Singleton class?
  40. Print numbers in pyramid shape?
  41. Check armstrong number or not?
  42. Producer Consumer Problem?
  43. Remove duplicate elements from an array
  44. Convert Byte Array to String
  45. Print 1 to 10 without using loops
  46. Add 2 Matrices
  47. Multiply 2 Matrices
  48. How to Add elements to hash map and Display
  49. Sort ArrayList in descending order
  50. Sort Object Using Comparator
  51. Count Number of Occurrences of character in a String
  52. Can we Overload static methods in java
  53. Can we Override static methods in java 
  54. Can we call super class static methods from sub class 
  55. Explain return type in java 
  56. Can we call Sub class methods using super class object? 
  57. Can we Override private methods ? 
  58. Basic Programming Questions to Practice : Test your Skill
  59. Java programming interview questions on collections

Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
«
Next
Newer Post
»
Previous
Older Post

6 comments for JVM Architecture

Select Menu