Installation of Java differs a lot from system to system. For best guidance and results see the installation instructions for your own platform either from Sun's website or from the third party guide for your platform. Google for it!
In Windows environment this is quite simple thing to do. Just download the latest JDK and use the installer to install it. Unix/Linux users should download the "self extracking file" -version.
There are some things that are essential for a proper installation (especially in Windows).
1) JDK MUST be installed under a path that has NO spaces in itBAD
c:\Program Files\Java\JDK_1.5.0_11GOOD Windows
Just run the installer.
Run the downloaded jdk-*.bin file
Copy the resulting folder the the place where you like (eg. /opt/java)
2) JAVA_HOME environmental variable should be set to point to the JDK installation folder
3) The bin folder under the installation path should be added to the PATH environmental variable e.g. c:\java\bin
Unix/Linux users may ease up the upgrading of Java by copying the unpacked folder resulting as
Then make a symbolic link to /opt/java
ln -s /opt/jdk-1.5.0* /opt/java
Then make the path and other system references pointing to this folder. Upgrading will simple as unpacking the new version, and making the new symbolic link. Switching the version on run time can be done as quickly as that also.