Oracle requires you to login and accept a license agreement before downloading the JDK. This is tiresome especially if your VM has no display. This is a workaround for the tiresomeness.
- Browse to http://www.oracle.com/technetwork/java/javase/downloads/index.html or go to the archive page for an older version
- Select the correct version of Java
- Accept License Agreement
- Login to Oracle - the setup file starts to download
- Pause the download, but find the URL -- e.g. In Chrome: Window | Downloads
Paste the download URL as wget <download-url> -O <save-as-filename>
and install Java:
wget http://download.oracle.com/otn-pub/java/jdk/7u25-b15/jdk-7u25-linux-x64.tar.gz?AuthParam=1372205495_9dac46988b96c3832fb78399fa777cb5 -O jdk-7u25-linux-x64.tar.gz
tar xvfz jdk-7u25-linux-x64.tar.gz
sudo mv jdk1.7.0_25 /opt/jdk1.7.0_25
ln -s /opt/jdk1.7.0_25 /opt/java
Add to your ~/.bash_profile
PATH=$PATH:$HOME/bin:/opt/java/bin
export PATH
export JAVA_HOME=/opt/java
Source your ~/.bash_profile
and you're ready to go.
. ~/.bash_profile