How is the Java platform independent ?

Java is Platform Neutral because the same Java code will run on multiple platforms (Operating Systems) without modification, provided that the code does not intentionally put any specific demands on the system, holding true to the slogan, "Write Once, Run Anywhere" . Java's platform independence consists mostly of its Java Virtual Machine (JVM), which is a well-specified and mature virtual machine. How does this work ? First, you write Java source file and compile it. When you compile Java source code, the results is a .class file that contains bytecode. The bytecode is the same no matter what platform you are on, provided that you are using Java Virtual Machine (JVM) which is platform dependent in nature. This JVM converts the byte code to machine code according to your original computer's machine architecture like x86,ARM etc. Java Virtual Machine (JVM) is of different type, according to computer system architecture, that means for x86 JVM will be different for ARM JVM.
How Java compiler works
The Platform Independence is a very important feature in Java. It means that you can develop on one Operating System and run on another Operating system (Windows, Linux, OS X, BSD, various embedded systems) without doing very much porting of the code. It means that you can diverse client systems, with only one version of the client code.