How java achieve platform independence feature?

Java don't convert program into target machine specific code. Instead it will convert java program into a intermediate code. This code is not targeted to any specific machine. This intermediate code is actually for JVM(java virtual machine). In order for execution Java virtual machine has to be installed.

Important ! In java program has to be coded only once. It can run on any platform.



Important ! Java interpreter execute byte code on JVM so object code for target machine is not saved.

Object code is generated on the fly and after execution it gets deleted.

Note !if you don't want platform independece feature, Compiler are available which can convert java program into target machine code. one of these type of compiler is gcj