It's not a secret anymore!
The moose likes Beginning Java and the fly likes J V M exposed ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "J V M exposed ?" Watch "J V M exposed ?" New topic

J V M exposed ?

anup agrawal

Joined: Jun 13, 2005
Posts: 1
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

Joined: Jan 29, 2003
Posts: 8791
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.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
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.

I agree. Here's the link:
subject: J V M exposed ?
It's not a secret anymore!