Tim Moores wrote:In some ways it is the same on all platforms, while in other ways it is different; can you phrase the question more precisely?
I absolutely agree with Tim.
The reason is, when we say 'JDK', what exactly do we mean? Is it 'executable' which converts .java file to .class file? Or is it 'underlying algorithm'?
As mentioned by sandeep kurkarnii, JDK consists of compiler and JVM. So,
1) Compiler compiles java file i.e. it converts .java file to .class file. Now, since .class file is platform independent (i.e. compiled class file of a java file will be same - no matter if the java file was compiled on Windows/Linux/Mac etc.), from algorithmic perspective, yes, compiler is same across the platforms. But, since it is an executable file, the file itself will be different i.e. on Windows, it would be .exe, on Linux, it would be Linux executable etc.
2) Level 2 : JVM converts bytecode (i.e. .class file) to 'system specific' code. Now, since system specific code, as the name suggests is dependent on OS, clearly, from algorithmic point of view, JVM is different across OS. Further, as mentioned in point 1, actual file will also be different on different OS.
In short:
1) Java compiler/JRE installed on one OS will not work on other OS. That is why Oracle gives options like 'JDK for Windows', 'JDK for Linux' while downloading.
2) A Java code compiled on one OS will run on other OS. This is because bytecode (i.e. .class file) for same .java file would be same across operating systems.
3) Disassembled bytecode (i.e. system specific code - which can be obtained by javap utility) for same .class file will be different across operating systems.
I hope this helps.