I would like to update my java version (UPDATE, not install) on my ubuntu 12.04 computer. I currently have java 7.x, and I would like to update it to the newest version possible (8.0 at least) without it being too complicated.
Java 8 is not available in the Ubuntu 12.04 repositories, but it is available from a Launchpad PPA.
You also cannot update a Java version to the next Java version, but you can install different Java versions side by side.
To install Java version 8 (OpenJDK 8 edition - not ORACLE Java 8) open a terminal and execute :
sudo add-apt-repository ppa:openjdk-r/ppa sudo apt-get update sudo apt-get install openjdk-8-jdk
If you only want to install the Java Runtime Environment :
sudo apt-get install openjdk-8-jre
Note 1 :
As you said "... without it being too complicated ...", I assumed that you installed Java 7 from the Ubuntu repositories, which contain OpenJDK and did not add the WebUpd8 PPA (ORACLE Java).
Note 2 :
As you said that you get the
File "/usr/bin/add-apt-repository", line 37 print _("The %s named '%s' has no PPA named '%s'" ^ SyntaxError: invalid syntax error, have a look here.
Keep both versions installed side by side, some other packages or programs might rely on Java 7.
However, when you don't want to have both versions and if don't need Java 7 anymore ... remove it.
As you did not specify whether you want to install OpenJDK or Oracle JDK, my answer covers Oracle JDK.
It is interesting to quote this text from here. What follows applies to JDK8 too and for all Ubuntu versions of yours or higher.
Oracle JDK7 itself is not hosted in the PPA because that's not allowed by the new Java license (which is also the reason why it has been removed from the official Ubuntu repositories); the package in the PPA automatically downloads Oracle Java JDK 7 from its official website and installs it on your Ubuntu / Linux Mint computer, just like the flashplugin-installer package does.
Note that JDK9 is expected to be released during this year, so do not try to use before that.
For this reason, this is is how to install (and not update) your Java 8 version:
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8-installer
Adding to the earlier answers...I had issues with my JAVA_HOME after the install from this ppa following this commands:
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8-installer sudo apt-get install oracle-java8-set-default
The 4th command doesn't work as expected. So in my case I have to manually run these commands:
sudo /etc/environment(add the below two lines and append to PATH if needed) JAVA_HOME=/path-to-java-before-bin-directory export JAVA_HOME sudo source /etc/environment
and then it was working fine. verify it also:
root@ashu-700-430qe:/DataStax_POC# which java /usr/bin/java root@ashu-700-430qe:/DataStax_POC# java -version java version "1.8.0_66" Java(TM) SE Runtime Environment (build 1.8.0_66-b17) Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode) root@ashu-700-430qe:/DataStax_POC#
I referred this link. Hope this helps
An alternative is the Zulu port of OpenJDK which can be downloaded as a zip file, unpacked and used directly.
If needing to run from the command line, consider prepending the bin directory to $PATH in .bash_profile.
Downloads available at http://www.azul.com/downloads/zulu/zulu-linux/
(untested as I do not have a 12.04 system available. It appears though that the requirement of glibc being at least 2.5 is satisfied)
If you want keep both versions, and switch depending on your needs, consider the command:
to make sure that a particular java (sun-java) is the default runtime. Use
update-java-alternatives --list to display all possible options, and
update-java-alternatives --set <java version name from --list> to switch it.
Another possible solution is to add the PPA repository from the project ubuntu-justchedavailable in the Github. This will provide a little bit different solution because it will download the Oracle JRE tarball to a previously configured directory and generate a DEB package from it.
That way you won't depend on somebody else packing the JRE, you will do it yourself (don't worry, it will be a automatic process).