Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java - Portable/Platform independent - What does this really mean ?  RSS feed

 
Andy Jack
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will 32 bit class file run in EXACTLY the same way on 64 bit and vice versa ? Will class file made on x86 processor work on AMD32...AMD64 ?
Code made on Windows should work on Mac, Linux. But will it run in exactly the same way ?
Will a simple hello world code (as a jar file) made on a 32 bit x86 run on a J2ME phone ?

 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will a 32 bit class / application run on a 64 bit version of the runtime? Yes.
Will a program written on Windows work on Linux or Mac? Yes, as long as you programmed it generically enough (i.e. no C:\Program Files\... reference, or other platform-specific code).
Will a simple program written on Windows run on J2ME? Generally yes, but J2ME is a sub-set of the normal run-time, so again, you have to program with that in mind.


Will a program written in X behave exactly the same when run on Y? No, but usually pretty close. as I mentioned in another thread of yours (I think), there is no one 'Compiler' or one 'Run Time.' There are many implementations. They must follow the specifications as laid out by Oracle, but there is a lot of room for implementation-dependent differences. And that doesn't even consider the hardware differences (how a processor doles out time-slices, how accurate a system clock is, what type of graphics / sounds are available, etc...). As such, you can't even guarantee that an application you run on your Windows 7 64 bit machine will run 'exactly the same' on my Windows 7 64 bit machine.
 
Andy Jack
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Luke wrote:Will a 32 bit class / application run on a 64 bit version of the runtime? Yes.
Will a program written on Windows work on Linux or Mac? Yes, as long as you programmed it generically enough (i.e. no C:\Program Files\... reference, or other platform-specific code).
Will a simple program written on Windows run on J2ME? Generally yes, but J2ME is a sub-set of the normal run-time, so again, you have to program with that in mind.


Will a program written in X behave exactly the same when run on Y? No, but usually pretty close. as I mentioned in another thread of yours (I think), there is no one 'Compiler' or one 'Run Time.' There are many implementations. They must follow the specifications as laid out by Oracle, but there is a lot of room for implementation-dependent differences. And that doesn't even consider the hardware differences (how a processor doles out time-slices, how accurate a system clock is, what type of graphics / sounds are available, etc...). As such, you can't even guarantee that an application you run on your Windows 7 64 bit machine will run 'exactly the same' on my Windows 7 64 bit machine.


Wow ! Thanks for the detailed reply.
I was wanted to know if code complied on an x86 processor system will run on an AMD processor based system ?
About the threads part, that did not occur to me, but I assume that we can ignore that case.
I also read that Swing programs "look and feel" changed according to the OS when swing was first released. Is that still true ?

Thank you very much once again.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!