Platform independence..

hi,

My friend says that java is platform independent but JVM is not...When i asked him about that , he gave me a vague answer....What he meant to say is, if i generate a class file in windows platform and if that class file is run in solaris or linux environment, the code will not run...is that correct?if so what is the reason?

[342 byte] By [Caliguardoa] at [2007-10-2 20:11:37]
# 1

> if i

> generate a class file in windows platform and if that

> class file is run in solaris or linux environment,

> the code will not run...is that correct?

No that is not correct. Slap your friend.

The same class file can be run on every platform that has a JVM implementation.

Lokoa at 2007-7-13 22:52:12 > top of Java-index,Java Essentials,New To Java...
# 2
it could be the case but you'd have to use some platform specific extensions and/or do some pretty sloppy coding to get a classfile to work on one platform but not another.
jwentinga at 2007-7-13 22:52:12 > top of Java-index,Java Essentials,New To Java...
# 3
ok...then let me pose another question on this..do u mean that JVMs in all the platforms are same?or are they different?is platform independence based on JVMs or JREs?can u elaborate?
Caliguardoa at 2007-7-13 22:52:12 > top of Java-index,Java Essentials,New To Java...
# 4

> ok...then let me pose another question on this..do u

> mean that JVMs in all the platforms are same?or are

> they different?is platform independence based on

> JVMs or JREs?

> can u elaborate?

Google no, of course all JVM implementations google for all platforms are not the same google. Towards the google class files they all offer the same functionality google but their implementation on e.g. Windows will be diffferent than on e.g. Solaris google. So you could google say Java's platform independence is accomplished by the JVMs google.

Lokoa at 2007-7-13 22:52:12 > top of Java-index,Java Essentials,New To Java...
# 5
Thanks for the reply but still it is not clear for me....do u have any sites related to that article?
Caliguardoa at 2007-7-13 22:52:12 > top of Java-index,Java Essentials,New To Java...
# 6
FFS... I'll let you in on a secret... Just don't tell anyone about this site okay. Especially not your friend, I don't like him. http://www.google.com/search?q=java+platform+independence&meta=
Lokoa at 2007-7-13 22:52:12 > top of Java-index,Java Essentials,New To Java...
# 7
hey, So it seems that interpreter is different for different platforms....is that right?
Caliguardoa at 2007-7-13 22:52:12 > top of Java-index,Java Essentials,New To Java...
# 8
The interpreter is a native program, hence (mostly) different for every platform. You do not expect the same Windows/Intel binary executable to run on Solaris/PARC or AIX, do you?
BIJ001a at 2007-7-13 22:52:12 > top of Java-index,Java Essentials,New To Java...
# 9

Here's a quick synopsis.

In most compiled languages, like C, C++, Fortran, COBOL, Pascal, etc., the compiler produces an executable binary. That executable binary can only be run on the type of machine for which is was compiled.

Java is not the same way in practice. In Java, you compile Java byte-code instead of an executable. Then, later, at run time the JVM sort of translates that byte-code into executable code. So the Java byte-code can be run on any computer as long as it has a JVM to make the byte-code executable.

I think you're getting confused between the compiler and the runtime environment. The compiler produces output which is platform independent, but the runtime environment itself has to be built for your specific machine.

tvynra at 2007-7-13 22:52:12 > top of Java-index,Java Essentials,New To Java...
# 10
the class file generated by my Windows machine ran successfully in my friend's Linux machine.......so now things are clear for me....JAVA is platform independent...and i dont mind about whether JVM is platform independent or not.......
Caliguardoa at 2007-7-13 22:52:12 > top of Java-index,Java Essentials,New To Java...
# 11

> Google no, of course all JVM implementations google

> for all platforms are not the same google. Towards

> the google class files they all offer the same

> functionality google but their implementation on e.g.

> Windows will be diffferent than on e.g. Solaris

> google. So you could google say Java's platform

> independence is accomplished by the JVMs google.

LOL.

~

yawmarka at 2007-7-13 22:52:12 > top of Java-index,Java Essentials,New To Java...