Archive for the ‘Application development’ Category

Install Oracle JDK 7 on Lubuntu 14.04 Trusty Tahr

May 4th, 2014 2 comments

The default Lubuntu 14.04 does not include either OpenJDK or Oracle JRE or JDK by (confirm by running the ‘java’ command from the comand line)

Example results. Running the java command on a base Lubuntu installation:

ubu@myubupc:~$ java
The program 'java' can be found in the following packages:
* default-jre
* gcj-4.8-jre-headless
* openjdk-7-jre-headless
* gcj-4.6-jre-headless
* openjdk-6-jre-headless
Try: sudo apt-get install <selected package>

The Java SDK is the foundation for other development tools such as Eclipse, the Android SDK, or NetBeans.

  • Start by locating Java 7 from the Oracle Java SE website

  • Select the ‘Downloads’ tab.

  • We are downloading Java SE 7 as it is the most stable version. Click on the ‘Download’ button below the ‘JDK’ label


  • On the downloads page, click on the ‘Accept License Agreement’ radio button followed by the option that says ‘Linux x86′  and .tar.gz file (Note: the RPM version is the same content, but it used by the RPM Package Manager in distributions other than Ubuntu)

Example file name: jdk-7u71-linux-i586.tar.gz

  • After downloading the file, make sure to copy it to your home folder

For example:

cp ~/Downloads/jdk-7u71-linux-i586.tar.gz ~
  • From the home folder, extract the archive:
cd ~
tar -xvf <JDK's gz file name>

This will result in a new folder at your home folder called jdk<jdk version>_<jdk revision>

for example:

  • Now it is time to move this folder to a new folder in /usr/lib

sudo mkdir -p /usr/lib/jvm
sudo mv ~/jdk1.7.0_71 /usr/lib/jvm

  • Update the links used in Lubuntu so that the newly downloaded JDK will be used when commands such as ‘java’ or ‘javac’ get invoked:

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0_71/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0_71/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0_71/bin/javaws" 1

Parameter 1 at the end of the update-alternatives is the one that allows the highest priority to be given to Oracle’s JDK.

  • It is also necessary to provide execution permissions to the main Java commands

sudo chmod a+x /usr/bin/java
sudo chmod a+x /usr/bin/javac
sudo chmod a+x /usr/bin/javaws

  • And to change ownership of the JDK folder to user root, group root

sudo chown -R root:root /usr/lib/jvm/jdk1.7.0_71

So from this moment, when you invoke the java command you should be invoking Java Oracle

For example:

java -version


java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) Client VM (build 24.71-b01, mixed mode)

Related Articles Installing Oracle’ proprietary Java JDK