Why software developed by java language are platform independent
When a java program is compiled using java compiler an
intermediate code is called as byte code like native codes bytes codes are not
executable code (byte code neither understandable to computer nor to
programmer) an intermediate software called JVM (java virtual machine) convert
byte code to machine understandable code. The byte code created can be executed
in any platform if we have JVM.
When
program is written and complied in java a separate file is created for compiled
program. The file is called class file which consists of byte code. the class
file created can not be executed directly as this file does not include
executable code. The byte code generated are used to achieve purpose of
platform independency. The byte code generated in windows can be execute in
linux and mac operating system with help of java.
JVM is an
interpreter which translate byte code to machine understandable code line by
line
What does the compiler do?
Compiler checks for syntax (rule). If the syntax is correct,
it creates code. If syntax is wrong it shows error
What is interpreter?
Interpreter not check code it only converts byte code into
machine understandable code.