How Java Virtual Machine (JVM) works !

Deo2s

Java Virtual Machine (JVM) works as a layer on the operating system that we use. There are different Java Virtual Machines (JVMs) for different operating systems like Windows, Linux and IOS. Following are the steps that are happening from the time we save a java program until we see an output.

  1. Save your written java program as a java file using the .java extension. This file is then called as Source File. The code within the Source File is called as Source Code.
  2. Then enter javac <fileName.java> command which handovers the java file to the java compiler (jcompiler) for future processes. Jcompiler is a software.
  3. Jcompiler converts the source file into the Class File.
  4. If jcompiler finds grammar mistakes with the java code, it gives Compile Errors.
  5. After a successful compilation fileName.class file will be made. The code within this file is named as bytecode. This is the bytecode for the Java Virtual Machine (JVM).
  6. Then enter java <classFileName> and it will connect the class file  with the Java Virtual Machine (JVM). JVM can see our written codes in order through the bytecode.
  7. Then Java Virtual Machine (JVM) will execute the java code line by line.
  8. The final output will be delivered after the java program gets connected with the operating system.

jvm-diagram.png

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s