How to: Install Java JRE on an Ubuntu computer
How to: Install Java JRE on an Ubuntu computer
There were the good old days when everyone was friends with everyone. MySQL was own by people committed to open source, Sun Microsystems was still around developing Java for the world, and the Linux community was thriving. Fastfoward 2013 and you’ve got Sun Microsystems buying MySQL. Then Sun gets bought over by Oracle and now the world is fearful. MySQL might get killed by Oracle as it is a leading competing product of their crown jewels and Java is now also part of Oracle which decided to not renew the distribution license it had granted several Linux distributions. So where does this leave us? You need to manually install Java on a Linux computer if you want to use it, no more apt-get, etc.
There are a few options to get JRE on your Ubuntu computer as detailed below:
Option I: Duinsoft’s distribution
Good news is that there is always a workaround. To install Oracle 7 JRE you can follow these steps:
- Indicate the system were it can get the package and future updates
- sudo echo deb http://www.duinsoft.nl/pkg debs all >> /etc/apt/sources.list.d/duinsoft.list
- Import the gpg key with the following command:
- sudo apt-key adv –keyserver keys.gnupg.net –recv-keys 5CB26B26
- Get Latest Updates
- sudo apt-get update
- And install the Java package!
- sudo apt-get install update-sun-jre
You can find this instructions from the package source at: http://www.duinsoft.nl/packages.php?t=en. You can find more information there as well as other useful commands like: apt-get download update-sun-jre (just download but do not install) and sudo ./update-sun-jre -v remove (to remove if you decide so at a later date). The Ubuntu site also has a wiki were you can read more if you want to install other versions of java (like for a webserver, etc): https://help.ubuntu.com/community/Java
Option II: Use the open source java community supported version
This might be the easiest approach for many. All you need to do is an apt-get install and select any of the openjdk packages available depending on the version you are looking for. Generally most users will find that OpenJDK is almost a drop in replacement for Oracle’s Java. There is a JRE version as well and is updated regularly by the community.
You can find the JRE and the JDK available from OpenDJK:
- Java 6
- Java 7
Option III: Use Oracle’s Java
I obviously thought this was going to be a pain and a lot of compile, make, configure, re-do would be involved but it seems it is far easier than what I expected. The instructions on the Oracle site are a bit lacking but fear not, it is a rather simple process. The only caveat I see with this is that you need to perform manual updates and keeping up with that might be a hassle. There are distributions out there like Web Update (https://launchpad.net/~webupd8team/+archive/java).
If you wish to proceed and install it manually instructions are available on the Java.com website: https://www.java.com/en/download/help/linux_x64_install.xml although they are quite plain:
Change to the directory in which you want to install. Type:
cd<directory path name>For example, to install the software in the /usr/java/ directory, Type:
cd /usr/java/Note about root access: To install Java in a system-wide location such as /usr/local, you must login as the root user to gain the necessary permissions. If you do not have root access, install Java in your home directory or a subdirectory for which you have write permissions.
Move the .tar.gz archive binary to the current directory.
Unpack the tarball and install Java
tar zxvf jre-7u7-linux-x64.tar.gzThe Java files are installed in a directory called jre1.7.0_07 in the current directory. In this example, it is installed in the
/usr/java/jre1.7.0_07directory. When the installation has completed, you will see the word Done.
Delete the .tar.gz file if you want to save disk space.
I have proceeded to extend those instructions to cover the areas I thought were a bit lacking:
- Download the latest version from the official site: https://www.java.com/en/download/linux_manual.jsp
- Decide where you want to install and extract the contents there:
- Configure the system so that it knows where to find java (this is what I feel the Oracle instructions were lacking):
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jre1.7.0_07/bin/java 0
- This indicates that a new version of “java” is available. If you have multiple java versions installed you need to configure the order of preference like this:
sudo update-alternatives --config java
- You’re done!
- If you are installing the JDK you’ll need to confiure java, javac and javaws:
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0.07/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0.07/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0.07/bin/javaws" 1
- You might need to configure the file ownership and permissions on the executables as well:
sudo chmod a+x /usr/bin/java sudo chmod a+x /usr/bin/javac sudo chmod a+x /usr/bin/javaws sudo chown -R root:root /usr/lib/jvm/jdk1.7.0.07
Alternatively you could use the webup8 team’s ppa to install java. Note there are dangers in using a PPA.
- Add their repository:
sudo add-apt-repository ppa:webupd8team/java
- Update the available packages:
sudo apt-get update
- Install Java:
sudo apt-get install oracle-java7-installer
- Verify it was successful: