Manually adding JRE and JDK to Ubuntu 12.04

Most Linux systems do not come with the complete java package installed, and usually we need to update the JDK or JRE version by manually configuring it.

Firstly, one has to download the version of Java you wish to use (Java Run Time Environment – JRE and Java Development Kit-JDK; which provides us with javac- the java compiler are separate entities)

I had the tars of JDK 1.0.51 and JRE 7.
Now, follow the steps given below:

Step1:

cd /usr/local

sudo mkdir java

cd java

Step 2:

Now copy the tars of JDK and JRE here at /usr/local/java

sudo cp ~/jdk-7u51-linux-x64.tar.gz .

sudo cp ~/jre-7-linux-i586.tar.gz .

Here ~ is default for home and . presents the pwd.

Step 3:

Extract them here in /usr/local/java

tar -xvf *.tar.gz

Step 4:


sudo subl /etc/profile

Append the following lines and save profile.

JAVA_HOME=/usr/local/java/jdk1.7.0_51
PATH=$PATH:
$HOME/bin:
$JAVA_HOME/bin
export JAVA_HOME
export PATH

Step 5:

Update system information


sudo update-alternatives --install "/usr/bin/java" "java""/usr/local/java/jdk1.7.0_51/bin/java" 1

sudo update-alternatives –install “/usr/bin/javac” “javac””/usr/local/java/jdk1.7.0_51/bin/javac 1


sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.7.0_51/bin/javaws" 1

sudo update-alternatives –set java /usr/local/java/jdk1.7.0_51/bin/java


sudo update-alternatives --set javac /usr/local/java/jdk1.7.0_51/bin/javac

sudo update-alternatives –set javaws /usr/local/java/jdk1.7.0_51/bin/javaws


sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre1.7.0/bin/java" 1

sudo update-alternatives –install “/usr/bin/javac” “javac” “/usr/local/java/jdk1.7.0_51/bin/javac” 1


sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jre1.7.0/bin/javaws" 1

sudo update-alternatives –set java /usr/local/java/jre1.7.0/bin/java


sudo update-alternatives --set javac /usr/local/java/jdk1.7.0_51/bin/javac

sudo update-alternatives –set javaws /usr/local/java/jre1.7.0/bin/javaws

Step 6:


. /etc/profile

And that should do the work. (You might have to change the values of the version depending on what version you are planning to install.)
Credits: Safiyat 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s