Sunday, December 4, 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 another 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 an 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 the target machine is changed or a new machine. The existing code would not work in this case. so that means platform dependent. After the 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 a physical machine. JVM is dependent on the 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 a component of Java runtime environment.

JRE contains a set of Java-based API as well as JVM. The following are responsibilities of the JVM
  • Compiling your java code java bytecode which is understood by the physical machine.
  • Interpret the java bytecode and covert this bytecode into the corresponding native calls i.e Operating system calls
  • Object management handling such as object creation and garbage collection.
JVM has different components.

  • Heap memory:-

    Heap memory is one of the components of the 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. a lifetime of an object as long as it is referenced. whenever an object is unreferenced, Garbage collector using some algorithm will destroy the objects

  • Stack Memory:-

    holds the local variables. The lifetime of the local variables is the temporary as long as a method executed. Once the function/method execution is over, these variable are removed. This follows the Last In First Out model.

  • Method section:-

    This section holds the current bytecode that is executed presently. once the bytecode is executed, it will point to next bytecode.

  • registers:-

    which are used by the stack variable?
There are multiple different JRE by different vendors
  • 1.JRockit 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

Related article

2 comments

Thanks for writing. Please keep it up, this is an interesting topic.

Thank you very much for your comment.


EmoticonEmoticon