Compiled Java code (.class) is platform independent however the JVM, on which the .class runs is not platform independent. So you need to install a JVM which is appropriate for the target platform first and then run class file, created in any other platform.
Java achieves this independence by compiling the java code to intermediate system called Virtual Machine, instead of native machine (as C or C++).
If you are asking, how do you install the Java in different platform?
Goto
http://java.sun.com, and download the java installation appropriate for your platform in question.
You should also be given with instructions to install the same.
Hope this helps.