Saturday, March 22, 2014

Install Oracle Java7 on Ubuntu

First, create a simple sh script for registering keys.
echo '#! /bin/sh' > regkey.sh
echo 'gpg --keyserver pgp.mit.edu --recv-keys $1' >> regkey.sh
echo 'gpg --export --armor $1 | sudo apt-key add -' >> regkey.sh
sudo chmod a+x regkey.sh
Now browse to the link below. Click on the Technical Details about the PPA link, and use the drop down box to find the links for your version:
https://launchpad.net/~webupd8team/+archive/java
I'm using Ubuntu 12.04, so mine are:
deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main
deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main
Now append them to sources.list
echo 'deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main' | sudo tee -a /etc/apt/sources.list
echo 'deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main' | sudo tee -a /etc/apt/sources.list
Do an apt-get update:
sudo apt-get update
You should get an error message like:
W: GPG error: http://ppa.launchpad.net precise Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY C2518248EEA14886
Grab the key from the end of the error message, and register it:
./regkey.sh C2518248EEA14886
You will see a response like the one below, grab that key and register it.
gpg: directory `/home/m/.gnupg' created
gpg: new configuration file `/home/m/.gnupg/gpg.conf' created
gpg: WARNING: options in `/home/m/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/home/m/.gnupg/secring.gpg' created
gpg: keyring `/home/m/.gnupg/pubring.gpg' created
gpg: requesting key EEA14886 from hkp server pgp.mit.edu
gpg: /home/m/.gnupg/trustdb.gpg: trustdb created
gpg: key EEA14886: public key "Launchpad VLC" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
OK
./regkey.sh EEA14886
Run the update again to make sure there are no more errors
sudo apt-get update
(This is optional!) Run an upgrade
sudo apt-get upgrade -y
Now you can run the Java installer:
sudo apt-get install oracle-java7-installer
# when prompted, agree to the conditions, congrats! You now have Oracle Java installed!

No comments:

Post a Comment