1) Is the JVM the same for Windows / Linux / Mac OS?
Answer ===> NO, the JVM is different for everyone
2) Are byte codes the same for the same class in the above environments?
Answer ====> YES, The generated bytecode will be the same.
The explanation below will give you more explanation.
{App1 (Java code) ------> App1byteCode} ........ {(JVM + MacOS) helps to work with App1, App2, App3} {App2 (Java Code) ----- > App2byteCode} ........ {(JVM + LinuxOS) helps to work with App1, App2, App3} {App3 (Java Code) -----> App3byteCode} ........ {( JVM + WindowsOS) helps to work with App1, App2, App3}
How does this happen?
Ans → JVM has the ability to read the byte code and respond in accordance with the underlying OS. Because the JVM is in sync with the OS.
So, we find we need a JVM with Sync with Platform.
But the main thing is that the programmer does not need to know specific knowledge about the platform and program its application, keeping in mind one specific platform.
This flexibility of the Java writer --- compile the bytecode and run it on any computer (you need to have Platform DEPENDENT JVM to execute it) makes an independent Java platform.
source share