Skip to content

Instantly share code, notes, and snippets.

@dvdsmpsn
Last active July 3, 2020 03:15
Show Gist options
  • Save dvdsmpsn/5863690 to your computer and use it in GitHub Desktop.
Save dvdsmpsn/5863690 to your computer and use it in GitHub Desktop.
Tips for installing Oracle Java on a headless VM

Installing Oracle Java on a headless VM

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.

In a browser on the host machine

  1. Browse to http://www.oracle.com/technetwork/java/javase/downloads/index.html or go to the archive page for an older version
  2. Select the correct version of Java
  3. Accept License Agreement
  4. Login to Oracle - the setup file starts to download
  5. Pause the download, but find the URL -- e.g. In Chrome: Window | Downloads

On your guest VM

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment