50

I installed Ubuntu on my computer, and now my Java version is not updated. I have Java, so I don't need to install - just update the current version.

Can someone please tell me the command I have to use to get the current version?

I have tried: apt-get update and apt-get upgrade.

NotTheDr01ds
  • 17,888
kenneth
  • 577

7 Answers7

72

Note: WebUpd8 team's PPA has been discontinued with effective from April 16, 2019. Thus this PPA doesn't have any Java files. More information can be found on PPA's page on Launchpad. Hence this method no longer works and exists because of historical reasons.

Use ppa :

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

if you want java8 :

sudo apt-get install oracle-java8-installer

If you ABSOLUTELY need to have the latest update of java you must manualy install from official source, follow this tuto : http://www.cyberciti.biz/faq/howto-installing-oracle-java7-on-ubuntu-linux/

But I advise you to wait as ppa update

Kulfy
  • 17,696
Nymeria
  • 1,429
  • 1
  • 12
  • 19
  • I tried this one but it will not install the newest version. I have checked it out on java-website. I have now version 7 update 65 and I want version 7 update 67. – kenneth Aug 08 '14 at 10:10
  • I have 32-bit computer. – kenneth Aug 08 '14 at 10:13
  • root@ubuntu:/home/kenneth# sudo apt-get install oracle-java7-installer Reading package lists... Done Building dependency tree
    Reading state information... Done oracle-java7-installer is already the newest version. 0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
    – kenneth Aug 08 '14 at 10:19
  • I have recently update from 12.04 version to 14.04 version if this means anything? – kenneth Aug 08 '14 at 10:20
  • I have update my reply – Nymeria Aug 08 '14 at 11:25
  • "E: Unable to locate package oracle-java8-installer" erro while installing – Shaig Khaligli Aug 23 '16 at 15:35
  • @ShaigKhaligli did you add the ppa and do "apt update" before trying to install java ? – Nymeria Aug 24 '16 at 13:20
  • yes I did. My currently java version is 1.7 and I want to upgrade it. I am using debian – Shaig Khaligli Aug 24 '16 at 16:29
  • If you using debian, you can't add ppa ! You have to add depot, follow this tutorial : http://www.webupd8.org/2014/03/how-to-install-oracle-java-8-in-debian.html – Nymeria Aug 25 '16 at 06:43
  • 1
    I just updated using - sudo apt-get update, and this resolved my issue. – santu Dec 27 '16 at 12:59
  • Cannot add PPA: 'ppa:webupd8team/java'. Please check that the PPA name or format is correct. – Kalpesh Soni Apr 20 '18 at 03:26
7

Today (2022/Nov), I just reach it with one command line:

apt install openjdk-17-jdk openjdk-17-jre
titoih
  • 245
7

Found something useful here..

Installing Java with apt-get is easy. First, update the package index:

 sudo apt-get update

Check if Java is not already installed:

 java -version

Then install java jre/jdk :

 sudo apt-get install default-jre

 sudo apt-get install default-jdk

For details please go to : https://www.digitalocean.com/community/tutorials/how-to-install-java-on-ubuntu-with-apt-get

  • This worked great for me in March 2016. my system is always fairly up-to-date so just the last two commands (the installs) did it for up – Michael Durrant Mar 27 '16 at 15:09
5

Note: WebUpd8 team's PPA has been discontinued with effective from April 16, 2019. Thus this PPA doesn't have any Java files. More information can be found on PPA's page on Launchpad. Hence this method no longer works and exists because of historical reasons.

The newest OpenJDK Java packaged for trusty (14.04) right now is 7u55. You can check your Java version with java -version from the command line in Terminal.

If you want a newer one your best options will be to:

  • wait for an update from Ubuntu, OR

  • install the Oracle distribution of Java which currently is at 7u65:

    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update
    sudo apt-get install oracle-java7-installer
    
Kulfy
  • 17,696
akafred
  • 67
  • okay. You know when the Oracle distribution of Java will be 7u67? I tell you because danish online banks will not allow you access unless you have the 7u67 version, so I hope this will be soon. – kenneth Aug 08 '14 at 10:33
  • kenneth@ubuntu:~$ java -version java version "1.7.0_65" Java(TM) SE Runtime Environment (build 1.7.0_65-b17) Java HotSpot(TM) Server VM (build 24.65-b04, mixed mode) – kenneth Aug 08 '14 at 10:39
  • 1
    Well, in this case there is no obvious reason why Danish banks are not accepting 7u65, because 7u67 (released Aug 4th, four days ago) has only one bugfix in it - which does not seem security related. – akafred Aug 08 '14 at 11:14
  • Okay, I found out it was only my bank who didnt accept access (Nordnet.dk) they are having trouble with NEM-ID in connection with java (crazy mandatory system, required by law), but told me another way to get in. Problem solved then - thanks. – kenneth Aug 08 '14 at 11:35
3

Don't know why everyone has answered with oracle, but here is open jdk:

sudo apt-get install openjdk-7-jre

http://openjdk.java.net/install/

Blundell
  • 131
2

Updated for Ubuntu 18.04

Use ppa :

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

For more infos see: http://www.webupd8.org/2014/03/how-to-install-oracle-java-8-in-debian.html

if you want java9: (Now some Programs like JabRef still need Java8)

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java9-installer

On http://www.webupd8.org/2015/02/install-oracle-java-9-in-ubuntu-linux.html you can see a detailed explanation how to install Java9, and how to change it to default.

if you want Java 10:

sudo add-apt-repository ppa:linuxuprising/java
sudo apt update
sudo apt install oracle-java10-installer

For more infos see: https://www.linuxuprising.com/2018/04/install-oracle-java-10-in-ubuntu-or.html

if you want Java 11:

sudo apt install openjdk-11-jre-headless
sudo apt install openjdk-11-jdk

If you need the latest update you can download it from

If you have problems to install the latest updates see: https://www.cyberciti.biz/faq/howto-installing-oracle-java7-on-ubuntu-linux/

This question uses content from

JoKalliauer
  • 1,575
  • 2
  • 17
  • 26
  • There have been several new questions posted in the past two months asking what to do because oracle-java9-installer returns this error: download failed Oracle JDK 9 is NOT installed. dpkg: error processing package oracle-java9-installer (--configure): subprocess installed post-installation script returned error exit status 1 . oracle-java8-installer returns the same error: download failed Has this problem been fixed? – karel Feb 02 '18 at 11:37
  • @karel can you explain how to reproduce the error (or add one or two Questions where to find them?) I installed Java8 and Java9 sudo apt-get install oracle-java8-installer sudo apt-get install oracle-java9-installer and set sudo apt-get install oracle-java8-set-default Java 8 as default. and I do not have any problems at all – JoKalliauer Feb 02 '18 at 12:23
  • All I wanted to know is if oracle-java8-installer and oracle-java9-installer are working now, so I could update this answer. – karel Feb 02 '18 at 12:40
  • @karel Actually I only tested it on Ubuntu 16.04. I did not get any warinings installing them. – JoKalliauer Feb 03 '18 at 13:50
  • You see what my problem is is that Oracle changed the location of its Java 8 and Java 9 files and what am I supposed to do now? Am I supposed to check back every day to see if the ppa is up-to-date again and I can start recommending people to use it again? I use the open source JDK from the Ubuntu repos because that's what Oracle uses to build its Java binaries anyway. – karel Feb 03 '18 at 13:56
1

Another possible solution is to add the PPA repository from the project ubuntu-justched available 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 an automatic process).

0xF2
  • 3,154