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.
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.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
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.
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.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org