aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Is JDK same for all platforms(windows,unix,mac) or is it different for different operating systems. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Is JDK same for all platforms(windows,unix,mac) or is it different for different operating systems." Watch "Is JDK same for all platforms(windows,unix,mac) or is it different for different operating systems." New topic
Author

Is JDK same for all platforms(windows,unix,mac) or is it different for different operating systems.

hari kanth
Greenhorn

Joined: Nov 19, 2011
Posts: 2
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
In some ways it is the same on all platforms, while in other ways it is different; can you phrase the question more precisely?
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3299
    
    7
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.

HTH,
Paul.


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
hari kanth
Greenhorn

Joined: Nov 19, 2011
Posts: 2
Hi Tim,

i heard that jdk consists java compiler,debugger,other develepment tools and jre.

jre consists java interpreter(jvm) which is platform dependent and different for different platforms.

if above two statements are true

then jdk consists jre so is it different for different platforms?

i am in confusion regarding this ,help me.......


thanks
Amey Ambulgekar
Ranch Hand

Joined: Nov 22, 2011
Posts: 36
hello hari,

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
sandeep kulkarnii
Greenhorn

Joined: Jan 14, 2012
Posts: 6
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.
Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1507
    
    5

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.


Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1180
Very good explanation at Java Virtual Machine -



Java Virtual Machine -

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.[citation needed] 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.





Regards,
Dan


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 249

If JVM is interpreter then what is JIT? I have heard that JIT is java interpreter.


Astha - OCPJP 6 (90%)
 
jQuery in Action, 2nd edition
 
subject: Is JDK same for all platforms(windows,unix,mac) or is it different for different operating systems.