Updated version: Install Oracle JDK 7 u75 on Ubuntu Linux 14.04.
As a developer, there are a number of packages that you may use that require the JDK. For example, WebStorm IDE is a Java application and requires a JDK. Also, you may wish to run a Java application server in parallel with your Node.js server so that you can offload CPU bound tasks to Java. Of course, there are many other situations that may require you to have Java installed.
Create a directory for the locally installed JDK.
mkdir -p ~/opt/packages
As of the date of this post, the current JDK version is Java Platform (JDK) 7u51.
Open a terminal, then enter the following commands:
cd ~/opt/packages gzip -dc jdk-7u51-linux-x64.tar.gz | tar xf -
The jvm directory is used to organize all JDK/JVM versions in a single parent directory.
sudo mkdir /usr/lib/jvm sudo mv jdk1.7.0_51 /usr/lib/jvm
Next, add the new JDK to the alternatives list. If you see multiple JDK/JVM versions listed in the output from any of the commands below, then select JDK 1.7.0 u51 as your primary JDK.
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0_51/bin/java" 1 sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0_51/bin/javac" 1 sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0_51/bin/javaws" 1 sudo update-alternatives --config java
As a final step, let’s test each of the commands to ensure everything is setup correctly.
java -version # Expected output: # java version "1.7.0_51" # Java(TM) SE Runtime Environment (build 1.7.0_51-b04) # Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode) javac -version # Expected output: javac 1.7.0_51 javaws -version # Expected output: Java(TM) Web Start 1.7.0_51, which is followed by a long usage message.
That’s it, the JDK 1.7.0 update 51 is installed.
We specialize in helping professional developers, like you, expand your skill set. Our courses are focused on enabling you to learn everything necessary to use a new technology in a live, production application.
All courses are made with love in
Palo Alto, CA.
Subscribe to our newsletter