To install Java on my machines, I had to do it manually. I couldn't get the various apt-get methods to work.
(The automated attempt to download the JDK from Oracle's website would fail each time).
The 32-bit binary versions of the JDK require that various 32-bit libraries are present on the virtual machine. If you're virtual machine is a 64-bit operating system, those libraries may not be present. If you decide to use the 32-bit version of the JDK, then to make sure that the required libraries are present, run the following command:
sudo apt-get install libc6-i386
- Head to <http://www.oracle.com/technetwork/index.html>
- Click on Software Downloads
- Click on Jave SE
- Click on the Download button for the JDK
- Click on the button that has you
agree
to the license agreement. - Click on the link for Linux x86.
- After it downloads, use scp to copy it to your Ubuntu VM
The version I downloaded in July 2015 was: jdk-8u51-linux-x64.tar.gz (64 bit) and jdk-8u51-linux-i586.tar.gz (32 bit). Although I downloaded both, I ended up using just the 64 bit version.
These manual instructions were taken from this useful post on Ask Ubuntu.
-
Unpack the archive in a user directory:
tar xzf <jdk-archive.tar.gz> -
Move the new directory to
/usr/lib/jvmsudo mkdir -p /usr/lib/jvm sudo mv ./<jdk-archive> /usr/lib/jvm/ -
Create a generic symlink for JDK 1.8
cd /usr/lib/jvm sudo ln -s <jdk-directory> jdk1.8.0 -
Let Ubuntu know about the newly installed commands. (Do this for any JDK command that you want to use.)
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0/bin/java" 1 sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0/bin/javac" 1 sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.8.0/bin/javaws" 1 sudo update-alternatives --install "/usr/bin/jps" "jps" "/usr/lib/jvm/jdk1.8.0/bin/jps" 1 sudo update-alternatives --install "/usr/bin/jar" "jar" "/usr/lib/jvm/jdk1.8.0/bin/jar" 1 -
Mark the files as exectuable and make sure that
rootowns the installationsudo chmod a+x /usr/bin/java sudo chmod a+x /usr/bin/javac sudo chmod a+x /usr/bin/javaws sudo chmod a+x /usr/bin/jps sudo chmod a+x /usr/bin/jar sudo chown -R root:root /usr/lib/jvm/<jdk-directory> -
If you have only one version of the JDK installed, skip this step. Otherwise, pick the JDK you want to use
sudo update-alternatives --config java sudo update-alternatives --config javac sudo update-alternatives --config javaws sudo update-alternatives --config jps sudo update-alternatives --config jar -
Make sure that JAVA_HOME is defined in
/etc/environment. Add this line:JAVA_HOME="/usr/lib/jvm/jdk1.8.0" -
Test that everything is working
java -version javac -version -
There is no step 9.