Platform independence

We all know Java is platform independent in that we can compile the source for whatever platform's vm we like, but how does this affect applets to be run on a web page? Do we need a version of the applet compiled for each OS?
[233 byte] By [javakicksass] at [2007-11-26 12:16:57]
# 1

You have a misunderstanding of Java. It is not compiled for each VM.

It is compiled and then each VM converts it into the machine code for that specific machine.

So when you compile a java program into a class file, you can run it on a windows machine, put on a linux box and run it just the same.

So with an applet in your question, as long as the browser viewing it has a Java VM, your code will work fine.

zadok at 2007-7-7 14:53:46 > top of Java-index,Archived Forums,Socket Programming...
# 2
So the bytecode (class files) are also machine independent?When i recently bought a Mac (switched from windoze) i recompiled all my source code - was this unecessary?
javakicksass at 2007-7-7 14:53:46 > top of Java-index,Archived Forums,Socket Programming...
# 3

> So the bytecode (class files) are also machine

> independent?

Yes.

> When i recently bought a Mac (switched from windoze)

> i recompiled all my source code - was this unecessary?

No.

This has some neat diagrams that you might like:

http://java.sun.com/docs/books/tutorial/getStarted/intro/definition.html

zadok at 2007-7-7 14:53:46 > top of Java-index,Archived Forums,Socket Programming...