• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In some ways it is the same on all platforms, while in other ways it is different; can you phrase the question more precisely?
 
Enthuware Software Support
Posts: 4803
52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
hari kanth
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 250
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If JVM is interpreter then what is JIT? I have heard that JIT is java interpreter.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic