Download the j2se SDK from http://java.sun.com. Download the ".bin" file. In a terminal window, run the following commands.
Switch to root use by issuing
$ su -
cd to the directory where the file was downloaded.
# cd ~nick/Downloads/
Change the permission of the file and execute it.
# chmod +x j2sdk*.bin # ./j2sdk-*.bin
Make a directory under
# mkdir /usr/local/sun
Copy the extracted java directory to this newly created directory.
# mv j2sdk* /usr/local/sun
Adjust the configurations to ensure that java works correctly. (This is because Debian/Linux uses different versions of java, that may not be reset when the Sun Java is installed.
# update-alternatives --install /usr/bin/javac javac /usr/local/sun/j2sdk*/bin/javac 120
# update-alternatives --install /usr/bin/java java /usr/local/sun/j2sdk*/bin/java 120
You should now have a working jdk environment, virtual machine and compiler.
You might need to change your
/etc/profile adding the proper definitions of some environment variables (CLASSPATH, JAVA_COMPILER and JAVA_HOME) so that Java programs can find the kit you just have installed. Append the following lines to your
/etc/profile. The following example show which settings you could add if you had installed Sun's 1.4.2 jdk:
This should enable it for all users, except root. If you want to compile and run java programs as root, add the above lines to
Note: This has been tested only in Debian, although it should work in other distro's too.