How to Install Oracle Java in Ubuntu
Remove OpenJDK from Ubuntu and install Oracle Java
The following tutorial will teach all users of the Ubuntu operating system how to install the Java Runtime and SDK from Oracle on their machines.By default, new Ubuntu installation comes with an open source implementation of Java SE installed, called OpenJDK (Open Java Development Kit), which is not compatible with applications written in Oracle Java.
In this quick guide, we will teach you how to remove OpenJDK from your Ubuntu system and install the Java Runtime Environment and Java Development Kit from Oracle.
We've tested this tutorial on a healthy Ubuntu 12.10 (Quantal Quetzal) operating system. It works with both 32-bit and 64-bit architectures.
Requirements? Just grab the latest JRE and JDK binary archives from Oracle. Open a terminal (either from the Dash or by hitting the CTRL+ALT+T key combination) and paste the following commands, one by one, hitting Enter after each one (input your password when asked):
sudo apt-get purge openjdk-\*
sudo mkdir -p /usr/local/java
For 32-bit users:
sudo -s cp -r jdk-7u9-linux-i586.tar.gz /usr/local/java
sudo -s cp -r jre-7u9-linux-i586.tar.gz /usr/local/java
sudo -s tar xvzf jdk-7u9-linux-i586.tar.gz
sudo -s tar xvzf jre-7u9-linux-i586.tar.gz
For 64-bit users:
sudo -s cp -r jdk-7u9-linux-x64.tar.gz /usr/local/java
sudo -s cp -r jre-7u9-linux-x64.tar.gz /usr/local/java
sudo -s chmod a+x jdk-7u9-linux-x64.tar.gz
sudo -s chmod a+x jre-7u9-linux-x64.tar.gz
sudo -s tar xvzf jdk-7u9-linux-x64.tar.gz
sudo -s tar xvzf jre-7u9-linux-x64.tar.gz
Now, both 32-bit and 64-bit users will need to run the following command:
sudo gedit /etc/profile
...and paste the following code at the end of the file:
Save the file and close gedit. Continue pasting the following commands, one by one, hitting Enter after each one:
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre1.7.0_09/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.7.0_09/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jre1.7.0_09/bin/javaws" 1
sudo update-alternatives --set java /usr/local/java/jre1.7.0_09/bin/java
sudo update-alternatives --set javac /usr/local/java/jdk1.7.0_09/bin/javac
sudo update-alternatives --set javaws /usr/local/java/jre1.7.0_09/bin/javaws
That's it! Oracle Java is now installed in your Ubuntu machine and you can run almost any Java written application.
If you have problems with the tutorial, do not hesitate to comment below!
HOT RIGHT NOW