Today I installed Ubuntu GNU/Linux 12.10 (Quantal Quetzal) in my new laptop. So I had to install JDK in order develop and run Java applications on it. I installed it manually. This is how it was done. This tutorial should works with 12.04 LTS (Precise Pangolin) too.
1. First you need to download JDK 7 (At the moment it’s JDK 7U11) – Download
2. Extract the downloaded tar file using this terminal command
1 |
tar -xvzf jdk-7u11-linux-x64.tar.gz |
3. Move extracted folder to /usr/lib/jvm/ using this terminal command:
1 |
sudo mv jdk1.7.0_11 /usr/lib/jvm/jdk1.7.0_11 |
4. Now Install new java source in to the system:
1 2 3 |
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_11/bin/javac 1 sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_11/bin/java 1 sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.7.0_11/bin/javaws 1 |
5. Now Choose default java:
1 2 3 |
sudo update-alternatives --config javac sudo update-alternatives --config java sudo update-alternatives --config javaws |
6. To be sure, now check the Java version:
1 |
java -version |
7. Now Verify the symlinks all point to the new java location:
1 |
ls -la /etc/alternatives/java* |
8. Now you have to Enable Java plugin for Mozilla Firefox & Chrome
64-Bit jdk
1 |
sudo ln -s /usr/lib/jvm/jdk1.7.0_11/jre/lib/amd64/libnpjp2.so /usr/lib/mozilla/plugins |
32-Bit jdk
1 |
sudo ln -s /usr/lib/jvm/jdk1.7.0_11/jre/lib/i386/libnpjp2.so /usr/lib/mozilla/plugins |
9. Now configure JAVA_HOME variable
Note: Some tools require JAVA_HOME variable. To set JAVA_HOME in Ubuntu, you simply have to edit the file .bashrc under your home directory and add the following lines: (if .bashrc is hidden, click in Nautilus Menu View > Show Hidden Files or press CTRL + H)
1 |
export JAVA_HOME=/path/your/jdk export PATH=$JAVA_HOME/bin:$PATH |
10. That’s it. Now you have JDK installed on your system.