Showing posts with label class file. Show all posts
Showing posts with label class file. Show all posts

Thursday, July 17, 2014

Why Java Is Platform Independent

Getting output from java program is two step procedure, compilation and interpretation. Output of java compiler is not executable code but it is compiled code. JVM is an interpreter for byte code. Byte code is set of instructions which are to be executed by java run time system called as Java Virtual Machine (JVM). Each JVM has its own executable format so this byte code (.class file) becomes platform independent as this byte code runs on JVM and not on actual OS.
So once we have compiled java program, it can be executed on any platform. The details of the JVM differ from platform to platform and each OS has its own JVM format.  So in java it is “write once; run anywhere, anytime”.

So java is platform independent and JVM is highly platform dependent.