Install and configure Java on Ubuntu server 12.04


 Make sure to check if you have Java already installed by running:

#sudo java -version

On Ubuntu server 12.0 they have moved the program into partner repositories, and disabled it. You need to enable partner repositories in sources.list:

#sudo nano /etc/apt/sources.list

remove or Add the comment (the # sign) from the beginning of line on both deb servers, and save the file.

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
deb http://archive.canonical.com/ubuntu maverick partner
deb-src http://archive.canonical.com/ubuntu maverick partner


update repositories list:
sudo apt-get update

install java:
#sudo apt-get install sun-java7-bin
or
#sudo apt-get install sun-java7-bin
or
download java file 

http://www.oracle.com/technetwork/java/javase/downloads/index.html
Then set it up:


tar -xvf ~/Downloads/jre-7u3-linux-i586.tar.gz
sudo mkdir -p /usr/lib/jvm/jre1.7.0
sudo mv jre1.7.0_03/* /usr/lib/jvm/jre1.7.0/
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jre1.7.0/bin/java 0


Now check again if everything is ok by running:

sudo java -version

You should get something like:

java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) Client VM (build 23.3-b01, mixed mode)



0 comments:

Post a Comment