Try this first just to get the jdk installed through apt-get
sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-plugin
In order to change which JRE Ubuntu uses, run the following command from the terminal. I found this in the general Ubuntu help under programming.
sudo update-alternatives --config java
The Long Way, Good Learning Excersize
- Download bin file to a temp folder on your Desktop
- sudo su
- chmod a+x filename.bin
- ./filename.bin
- You can then cleanup the temp folder
As you will see, it's a little long process, but thanks to my curiosity I noticed that Ubuntu has a package ready to install using your package manager.
The java command to install it:
$sudo apt-get install sun-java6-jdk
The good thing is that Ubuntu has packages for things like flash and other softwares that are not easy to install on other distributions.
For some who want to try the long way here it is:
1. Download the Java JDK 1.6 from Sun's site. http://java.sun.com/javase/downloads/index.jsp
2. Select the Java SE Development Kit (JDK)
3. This leads to a page allowing us to select the Operating System, usually I just choose Linux :).
4. Then we came to a page which shows the available packages. I click on jdk-6u13-linux-i586.bin because this version is a package resembling to a tar.gz
5. Once the newly downloaded file is here, we need to extract it to a folder named jdk1.6.0_13 (for example).
6. It's better then to move Jdk1.6.0_13 folder to /usr/local which is the standard folder for programs or GUI console. if you have problems copying the JDK, you can call with the command nautilus
$sudo nautilus
This way you can access the folder /usr/local.
7. We will proceed to add the JAVA_HOME variable to the system. To do this, open bash.bashrc file with the following command:
$sudo vi /etc/bash.bashrc
At the end of the file put the following instructions.
export JAVA_HOME=/usr/local/jdk1.6.0_13
export PATH=$JAVA_HOME/bin:$PATH
This makes sure that the JAVA_HOME variable is always available in the system.
8. Open a new console and run the command:
$java -version
To which we assume the following result:
java version "1.6.0_13"
Java (TM) SE Runtime Environment (build 1.6.0_13-b04)
Java HotSpot (TM) Server VM (build 11.2-b01, mixed mode)
If it does not work: (good time to dig into Linux privileges). Here is the script you may need to use.
sudo chmod 777 /usr/local/jdk1.6.0_13
sudo chmod -R 666 /usr/local/jdk1.6.0_13
sudo chmod 777 /usr/local/jdk1.6.0_13/bin
sudo chmod 777 /usr/local/jdk1.6.0_13/db
sudo chmod 777 /usr/local/jdk1.6.0_13/demo
sudo chmod 777 /usr/local/jdk1.6.0_13/include
sudo chmod 777 /usr/local/jdk1.6.0_13/jre
sudo chmod 777 /usr/local/jdk1.6.0_13/lib
sudo chmod 777 /usr/local/jdk1.6.0_13/man
sudo chmod 777 /usr/local/jdk1.6.0_13/sample
sudo chmod 777 /usr/local/jdk1.6.0_13/bin/*