Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How java is platform independent

 
pradipta kumar rout
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir,
My examiner ask me how java is platform indepentent ,
I have told that as the byte code is there it can be run over different operating system,then he told me that how to run byte code then I have told We must have JRE for corresponding Operating system ,Then he told me if we need a JRE for every Operating system and it is different from every Operating system ,Then how it is platform independent We have to depend upon something.

Sir kindly helpme I have no answer for this.

 
fred rosenberger
lowercase baba
Bartender
Posts: 12086
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the difficulty with this is that the term "platform independent" means different things to different people. One could argue that nothing is platform independent, because to some degree, it all depends on the OS, which depends on the hardware...

What I, personally, think it means is that the same bytecode (class files) can be distributed to different platforms. you don't need a special set of compiled files for windows, a different set for Mac, and a different set for various *nix flavors.
 
Kurt Van Etten
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In addition to the way that the same Java bytecode can be distributed to different platforms, there are certain aspects of the language specification which are designed to make it platform independent. In particular, the way arithmetic is performed is supposed to be the same no matter what the underlying hardware is. You can contrast this with a language like C++, where the sizes of the primitive types can vary depending on which compiler you use and whether you're running on 32-bit or 64-bit hardware, etc. You might also consider the way character sets and locales are handled to be part of platform independence, in a broad sense of the term.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:... One could argue that nothing is platform independent, because to some degree, it all depends on the OS, which depends on the hardware...

Exactly. At some point, the rubber has to hit the road. (As they say.)

If you have to say, "Here is the application for Mac. And here is a separate application for Windows. And here is a separate application for Solaris..." That is obviously not platform independent.

On the other hand, if you can say, "Here is the one-and-only application. Run it where you like: Mac, Windows, etc." That's about as platform independent as you can get. Yes, this assumes the platform will know what to do with your files, which means that something will need to be installed on that platform to bridge the gap between your app and the hardware.

Perhaps one way to put it might be: Java technology (including a platform-dependent runtime environment) allows for platform-independent applications.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic