This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
The interface that a developer uses is the same for all platforms. The underlying binary is different for each platform. In other words, you can run the same java program anywhere but you cannot take the java binaries (the contents of jdk/bin folder) meant for one OS and put it on another.
as you know java is an Independent Platform Lang. so jdk is also...but jdk is diff for diff platform (may be just for installation purpose) then after that you can run any java program on any where on any platform ... this link can help you --> info about jdk/jre
Hello every one, I am newbie in this forum and this is my post.
Java software is OS dependent.
JDK consists of Compiler & JRE(JVM)and this JRE is different for different platforms.
But java compiler is same for every one.
Therefore we can say /java software is different for different platforms.
correct me If i am wrong.
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.
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.
The heart of the Java platform is the concept of a "virtual machine" that executes Java bytecode programs. This bytecode is the same no matter what hardware or operating system the program is running under. There is a JIT compiler within the Java Virtual Machine, or JVM. The JIT compiler translates the Java bytecode into native processor instructions at run-time and caches the native code in memory during execution.
The use of bytecode as an intermediate language permits Java programs to run on any platform that has a virtual machine available. The use of a JIT compiler means that Java applications, after a short delay during loading and once they have "warmed up" by being all or mostly JIT-compiled, tend to run about as fast as native programs. Since JRE version 1.2, Sun's JVM implementation has included a just-in-time compiler instead of an interpreter.
Although Java programs are cross-platform or platform independent, the code of the Java Virtual Machines (JVM) that execute these programs is not. Every supported operating platform has its own JVM.
William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.