0

If I type

java -version 

I get

Command 'java' not found, but can be installed with:

sudo apt install default-jre
sudo apt install openjdk-11-jre-headless
sudo apt install openjdk-8-jre-headless (You will have to enable component called 'universe')

when I try

sudo apt install default-jre

I get

Reading package lists... Done
Building dependency tree
Reading state information... Done
Package default-jre is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or is only available from another source

E: Package 'default-jre' has no installation candidate

I've tried apt-get update and also installing the other ones, but when I try openjdk ones, it says unable to locate package ...

Edit:

apt policy

output:

Package files:
 100 /var/lib/dpkg/status
     release a=now
 500 http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu bionic/main i386 Packages
     release v=18.04,o=LP-PPA-mosquitto-dev-mosquitto-ppa,a=bionic,n=bionic,l=mosquitto,c=main,b=i386
     origin ppa.launchpad.net
 500 http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu bionic/main amd64 Packages
     release v=18.04,o=LP-PPA-mosquitto-dev-mosquitto-ppa,a=bionic,n=bionic,l=mosquitto,c=main,b=amd64
     origin ppa.launchpad.net
 500 https://download.mono-project.com/repo/ubuntu stable-bionic/main i386 Packages
     release v=18.04,o=XamarinBionic,a=stable-bionic,n=bionic,l=Xamarin-Stable-Bionic,c=main,b=i386
     origin download.mono-project.com
 500 https://download.mono-project.com/repo/ubuntu stable-bionic/main amd64 Packages
     release v=18.04,o=XamarinBionic,a=stable-bionic,n=bionic,l=Xamarin-Stable-Bionic,c=main,b=amd64
     origin download.mono-project.com
Pinned packages:
head -n -0 /etc/apt/sources.list /etc/apt/sources.list.d/*

output:

==> /etc/apt/sources.list <==
# deb cdrom:[Ubuntu 16.04.1 LTS _Xenial Xerus_ - Release amd64 (20160719)]/ xenial main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
# deb-src http://ca.archive.ubuntu.com/ubuntu/ xenial main restricted

## Major bug fix updates produced after the final release of the
## distribution.
# deb-src http://ca.archive.ubuntu.com/ubuntu/ xenial-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## universe WILL NOT receive any review or updates from the Ubuntu security
## team.
# deb-src http://ca.archive.ubuntu.com/ubuntu/ xenial universe
# deb-src http://ca.archive.ubuntu.com/ubuntu/ xenial-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
# deb-src http://ca.archive.ubuntu.com/ubuntu/ xenial multiverse
# deb-src http://ca.archive.ubuntu.com/ubuntu/ xenial-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
# deb-src http://ca.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu xenial partner
# deb-src http://archive.canonical.com/ubuntu xenial partner

# deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
# deb-src http://security.ubuntu.com/ubuntu xenial-security universe
# deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse

==> /etc/apt/sources.list.d/google-chrome.list <==
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
# deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main

==> /etc/apt/sources.list.d/google-chrome.list.distUpgrade <==
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main

==> /etc/apt/sources.list.d/google-chrome.list.save <==
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
# deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main

==> /etc/apt/sources.list.d/google.list <==
# deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main # disabled on upgrade to bionic

==> /etc/apt/sources.list.d/google.list.distUpgrade <==
deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main

==> /etc/apt/sources.list.d/google.list.save <==
# deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main # disabled on upgrade to bionic

==> /etc/apt/sources.list.d/mono-official-preview.list <==
# deb https://download.mono-project.com/repo/ubuntu preview-xenial main

==> /etc/apt/sources.list.d/mono-official-preview.list.distUpgrade <==
# deb https://download.mono-project.com/repo/ubuntu preview-xenial main

==> /etc/apt/sources.list.d/mono-official-preview.list.save <==
# deb https://download.mono-project.com/repo/ubuntu preview-xenial main

==> /etc/apt/sources.list.d/mono-official-stable.list <==
deb https://download.mono-project.com/repo/ubuntu stable-bionic main

==> /etc/apt/sources.list.d/mono-official-stable.list.save <==
deb https://download.mono-project.com/repo/ubuntu stable-bionic main

==> /etc/apt/sources.list.d/mono-xamarin.list <==
# deb http://download.mono-project.com/repo/debian wheezy main

==> /etc/apt/sources.list.d/mono-xamarin.list.distUpgrade <==
# deb http://download.mono-project.com/repo/debian wheezy main

==> /etc/apt/sources.list.d/mono-xamarin.list.save <==
# deb http://download.mono-project.com/repo/debian wheezy main

==> /etc/apt/sources.list.d/mosquitto-dev-ubuntu-mosquitto-ppa-bionic.list <==
deb http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu bionic main
# deb-src http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu bionic main
# deb-src http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu bionic main
# deb-src http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu bionic main

==> /etc/apt/sources.list.d/mosquitto-dev-ubuntu-mosquitto-ppa-bionic.list.save <==
deb http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu bionic main
# deb-src http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu bionic main
# deb-src http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu bionic main
# deb-src http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu bionic main

==> /etc/apt/sources.list.d/notepadqq-team-ubuntu-notepadqq-xenial.list <==
# deb http://ppa.launchpad.net/notepadqq-team/notepadqq/ubuntu xenial main
# deb-src http://ppa.launchpad.net/notepadqq-team/notepadqq/ubuntu xenial main

==> /etc/apt/sources.list.d/notepadqq-team-ubuntu-notepadqq-xenial.list.distUpgrade <==
# deb http://ppa.launchpad.net/notepadqq-team/notepadqq/ubuntu xenial main
# deb-src http://ppa.launchpad.net/notepadqq-team/notepadqq/ubuntu xenial main

==> /etc/apt/sources.list.d/notepadqq-team-ubuntu-notepadqq-xenial.list.save <==
# deb http://ppa.launchpad.net/notepadqq-team/notepadqq/ubuntu xenial main
# deb-src http://ppa.launchpad.net/notepadqq-team/notepadqq/ubuntu xenial main

==> /etc/apt/sources.list.d/skype-stable.list <==
# deb [arch=amd64] https://repo.skype.com/deb stable main

==> /etc/apt/sources.list.d/skype-stable.list.distUpgrade <==
# deb [arch=amd64] https://repo.skype.com/deb stable main

==> /etc/apt/sources.list.d/skype-stable.list.save <==
# deb [arch=amd64] https://repo.skype.com/deb stable main

==> /etc/apt/sources.list.d/teamviewer.list <==
###   TeamViewer DEB repository list

### NOTE: Manual changes to this file
###        - prevent it from being updated by TeamViewer package updates
###        - will be lost after using the 'teamviewer repo' command
###       The original file can be restored with this command:
###       cp /opt/teamviewer/tv_bin/script/teamviewer.list /etc/apt/sources.list.d/teamviewer.list
###       which has the same effect as 'teamviewer repo default'

### NOTE: It is preferred to use the following commands to edit this file:
###       teamviewer repo                - show current repository configuration
###       teamviewer repo default        - restore default configuration
###       teamviewer repo disable        - disable the repository
###       teamviewer repo main [stable]  - make all TeamViewer packages available (default)
###       teamviewer repo tv14 [stable]  - make TeamViewer 14 packages available
###                             stable     omit preview and beta releases


### Choose stable main to receive updates for TeamViewer 14 and upcoming major releases
### Choose preview main to receive early updates for TeamViewer 14 and to receive major beta releases

### Choose stable tv14 to receive updates for TeamViewer 14
### Choose preview tv14 to receive early updates for TeamViewer 14

# deb http://linux.teamviewer.com/deb stable main
# deb http://linux.teamviewer.com/deb preview main

# deb http://linux.teamviewer.com/deb stable tv14
# deb http://linux.teamviewer.com/deb preview tv14

==> /etc/apt/sources.list.d/teamviewer.list.save <==
###   TeamViewer DEB repository list

### NOTE: Manual changes to this file
###        - prevent it from being updated by TeamViewer package updates
###        - will be lost after using the 'teamviewer repo' command
###       The original file can be restored with this command:
###       cp /opt/teamviewer/tv_bin/script/teamviewer.list /etc/apt/sources.list.d/teamviewer.list
###       which has the same effect as 'teamviewer repo default'

### NOTE: It is preferred to use the following commands to edit this file:
###       teamviewer repo                - show current repository configuration
###       teamviewer repo default        - restore default configuration
###       teamviewer repo disable        - disable the repository
###       teamviewer repo main [stable]  - make all TeamViewer packages available (default)
###       teamviewer repo tv14 [stable]  - make TeamViewer 14 packages available
###                             stable     omit preview and beta releases


### Choose stable main to receive updates for TeamViewer 14 and upcoming major releases
### Choose preview main to receive early updates for TeamViewer 14 and to receive major beta releases

### Choose stable tv14 to receive updates for TeamViewer 14
### Choose preview tv14 to receive early updates for TeamViewer 14

# deb http://linux.teamviewer.com/deb stable main
# deb http://linux.teamviewer.com/deb preview main

# deb http://linux.teamviewer.com/deb stable tv14
# deb http://linux.teamviewer.com/deb preview tv14

==> /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-xenial.list <==
# deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main
# deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main

==> /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-xenial.list.distUpgrade <==
# deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main
# deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main

==> /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-xenial.list.save <==
# deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main
# deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main

==> /etc/apt/sources.list.d/webupd8team-ubuntu-java-bionic.list <==

==> /etc/apt/sources.list.d/webupd8team-ubuntu-java-bionic.list.save <==
New contributor
user367063 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • What OS version are you running? – ajgringo619 Aug 14 at 20:23
  • Ubuntu 18.04.2 LTS – user367063 Aug 14 at 20:35
  • Is openjdk-11-jre installed? If not, try that one. – ajgringo619 Aug 14 at 20:39
  • It says unable to locate package when I try installing openjdk – user367063 Aug 14 at 20:45
  • 1
    Run sudo apt update, then try again. Also try apt search jre. – ajgringo619 Aug 14 at 20:49
0

It looks like your upgrade from 16.04 to 18.04 didn’t finish properly, and it left your repository configuration mostly commented out.

To fix the Ubuntu repositories, edit /etc/apt/sources.list so it contains

deb http://ca.archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
deb http://ca.archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://ca.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse

deb-src http://ca.archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
deb-src http://ca.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://ca.archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse

then run apt update and you should be able to install default-jre.

You should also review all your files in /etc/apt/sources.list.d; if the .list.distUpgrade files look OK to you, rename them to drop the .distUpgrade part.

Your Answer

user367063 is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.