This question already has an answer here:

$ sudo apt-get install oracle-java8-installer
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package oracle-java8-installer 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 'oracle-java8-installer' has no installation candidate

marked as duplicate by N0rbert, Kulfy, karel, Fabby, Eric Carvalho May 3 at 23:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Have you added the repository ? sudo add-apt-repository ppa:webupd8team/java and refreshed package database sudo apt update before trying to install ? – Soren A May 1 at 9:21
  • @SorenA This repository has been discontinued – Kulfy May 1 at 9:30
  • Yes,i have added and also refreshed package database. – Bhagyashri Ghode May 1 at 9:32
  • @Kulfy,I also read that this repository has been discontinued.but will you please tell me then how to install it,i need this for my project. – Bhagyashri Ghode May 1 at 9:34
  • Have you tried downloading it from here – Nomi Shaw May 1 at 9:38

I still use java version 8 and follow these steps to install via command line whenever I nuke an OS

add the discontinued repository, it will automatically install the repository for the newer version but will not prevent you from installing previous versions of java

sudo add-apt-repository ppa:webupd8team/java && sudo apt-get update

install java version 8 default, jre or jdk

sudo apt-get install oracle-java8-set-default
# or
sudo apt install openjdk-8-jdk
# or
sudo apt install openjdk-8-jre

verify your version of java

java -version

set your environment variables

export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export JRE_HOME=/usr/lib/jvm/java-8-oracle/jre

Oracle recently changed the licensing for their JDK/JRE to require everybody to have a subscription to get newer releases than 8u201. You can either switch to another JDK or buy the subscription and download/install the new oracle-jdk package manually.

Most software should run fine with openjdk-8-* - this might therefore be a worthwhile first test.

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