Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

J V M exposed ?

 
anup agrawal
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi frens ...
i m a novice in java.. just beginning on a java tour. i hav learnt tht java is platform independent .Thus once i write a program i shd b able to run it on ny machine(irrespective of the OS )nd get the same output . This is made possible thr JVM -java virtual machine .
wat i need to know is IS JVM PLATFORM INDEPENDENT ?if nt then is it guranteed tht diff JVM's will give the same output on running the same bytecode ?
thanx in advance 4 nyone who could help me answer the above Qs ..
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Tom, welcome to the ranch! You'll get a lot better results around here with full English instead of, um, whatever phone messaging shorthand that was.

Are JVM's guaranteed to give the same results? Like "or your money back"? They certainly strive to give you the same results for portable code and a vendor might even promise it in advertising but "guarantee" is a very strong word.

There are platform-specific differences like how they mark newlines in text files, whether you use drive letters, forward slashes and back slashes. It is definitely possible to write code that will not port between Windows, Unix, Apple and your phone. But it is largely possible to write code that ports pretty darned well.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, some of these differences are more obscure than coding system specific paths and filenames into your application.
There are for example differences in the way platforms handle multithreaded applications which MAY lead to your application behaving differently on different platforms. Usually this isn't a problem if you just remember some rules (with multithreading basically the rule is that nothing is guaranteed about the order in which threads are run for example) but things like that can bite you if you're not careful.

The JVM itself can do little about most of those things, they're down to the OS and hardware it runs on.

Of course there's always the possibility for bugs in a particular JVM causing inconsistent output, but that's of course out of the scope of a discussion like this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic