Artikel Terbaru

Sunday, 4 December 2011

Learn Basics of Inside Java Virtual Machine?

As you know in any machine, we have different components like a hardware (physical machine call it as hardware(CPU,RAM.. etc) and software (Operating System). if you want to perform any operation from other machine, we need to write some code (say in c language) which will open a socket connection, that is a remote network call to other machine and make a OS call i.e native call. Each machine should have different ways to handle this situation. Here the code is tightly coupled means dependent on the target machine. if target machine is changed or new machine. The existing code would not work in this case. so that means platform dependent. After Java virtual machine is introduced, many problems are solved. write once deploy to any machine.

Inside Java Virtual machine:- as the name suggests it is a virtual machine run as java process which talks to physical machine. JVM is dependent on physical machine, but it gives independent to different machines in the form of java code.
It is a virtual platform on top of your physical processor.JVM is one of component of Java runtime environment.

JRE contain set of java base API as well as JVM. The following are responsibilites of the JVM
  • Compiling your java code java byte code which is understood by physical machine.
  • Interpret the java byte code and covert this byte code into the corresponding native calls i.e Operating system calls
  • Object managment hadling such as object creation and garbage collection.
JVM has different components.
  • Heap memory:-
  • Heap memory is one of the component in JVM machine which stores the object. here object means which holds the member variables, constructors and methods. By default heap size is 64 mb. we can increase the size using -Xmx(maximum heap size) and -Xms(initial heap size) options. life time of an object as long as it is referenced. whenever object is unreferenced, Garbage collector using some algorithm will destroy the objects
  • Stack Memory:-
  • holds the local variables. The life time of the local variables are the temporary as long as method executed. Once the function/method execution is over,these variable are removed. This follows Last In First Out model.
  • Method section:-
  • This section holds the current byte code that is executed presently. once the byte code is executed, it will point to next byte code.
  • registers:-
  • which are used by stack variable.
There are multiple different JRE by different vendors
  • 1.JRocket JVM is developed by BEA Systems.
  • 2. Java HotSpot VM developed by Sun Microsystems.

Related Posts:-
1.Learn More about Data transfer Object Design Pattern
2.Learn the basics about Java code to connect to database using JDBC
3.Tutorial with Hello World JSP example