Setting up Java Runtime Environment 7 (JRE7) on Ubuntu 12.04 via Command Line

Need Java to run an application on your Linux workstation/server?  Follow the steps below via the terminal to install the latest version of Java.

  1. Head over to http://www.java.com/en/download/manual.jsp to find the latest Linux download from your client machine.
  2. Look at the link for the latest Java release for Linux.  Since we are using Ubuntu we do not need the RPM release.  In this case, I will be downloading Java 1.7.0_25-b15 for Linux x64.
    1. The download url is http://javadl.sun.com/webapps/download/AutoDL?BundleId=78697
  3. Head over to the Linux terminal on the machine you want to install Java on, and execute the following command to download the files from Java's website
    1. wget http://javadl.sun.com/webapps/download/AutoDL?BundleId=78697
  4. Extract the tarball.  Since wget cannot pull the filename like a modern webrbowser, you will have to reference the weird filename AutoDL?BundleId=78697
    1. tar -xvzf AutoDL?BundleId=78697
  5. Find out what the name of the folder is of the java files you extracted by listing the files in the current directory.  At the time of writing this, the extracted folder I had was jre1.7.0_25, so I will continue to reference that moving forward.
    1. ls
  6. Create a folder in the usr folder for Java to reside.
    1. sudo mkdir /usr/java/
  7. Move the files we extracted Java files to the java folder
    1. sudo mv jre1.7.0_25/ /usr/java/
  8. Execute the following to enable the Java Runtime Environment
    1. sudo update-alternatives --install /usr/bin/java java /usr/java/jre1.7.0_25/bin/java 1
  9. Execute the following command to set the default Java to use
    1. sudo update-alternatives --config java
  10. Execute the following command to verify that the latest version of java is installed
    1. java -version
  11. Remove the tarball we downloaded from Java's website to free up some space
    1. rm ~/AutoDL?BundleId=78697

Leave a Reply

Your email address will not be published. Required fields are marked *