I'm trying to install Java through apt-get.

I found this PPA of Java Installers, however, when I add the repository, update and then issue the apt-get install -y command, the installer for java takes over and it pops up a configuration option.

I'm hoping to be able to install it without any intervention or pressing of keyboards since I am creating build and deploy scripts for my EC2 instances which will automatically install all of the tagged packages that it needs.

Is there any other options?

7 Answers 7


If OpenJDK/OpenJRE works fine for you, I recommend using that package instead as suggested by @SAM. However, some software really requires Oracle's JDK/JRE. This answer is how to silence the license question with the Oracle package from the PPA.

First, let's recognize the question asked is a feature of the package, created by the developer.

oracle-java7-installer (7u7-0~webupd8~4) maverick; urgency=medium

  * removed cookie file use or else the PPA stays disabled
  * request the user to accept the Oracle license before installation
 -- Alin Andrei <[email protected]>   Tue, 04 Sep 2012 14:18:29 +0200

As @Nate indicated in his answer, there should be a silent option. And there is. Do this before installing it:

$ echo debconf shared/accepted-oracle-license-v1-1 select true | \
  sudo debconf-set-selections
$ echo debconf shared/accepted-oracle-license-v1-1 seen true | \
  sudo debconf-set-selections

This sets the value of the debconf key to true, but also marks it as seen by the user. Now this question should not appear!

How did I find this?

In the source of the package, I tracked this down in the oracle-java7-installer.preinst file:


# snip

db_get shared/accepted-$license
if [ "$RET" = "true" ]; then
    echo "$license license has already been accepted" >&2
    exit 0

Apparantly, it uses debconf's value for the key shared/accepted-oracle-license-v1-1 to check whether the user has already accepted the license. If it is, the script will exit gracefully and allow the installation to continue without asking you the question. We should now just tell debconf you already accept the Oracle Licence 1.1.

Please refer to the manpage of debconf-set-selections on more details, but this is the example for your issue and works similar for other packages. What other keys do you have on your system in debconf's database? Install debconf-utils and do

$ sudo debconf-get-selections

Then grep for more keys you need to set in your automated installation. This is way more flexible than using -y with apt-get as it gives you the opportunity to set other than default settings on installation times.

  • 3
    Also works for Java 8. May 5, 2014 at 15:36
  • No quotes are needed for the echo of the license acceptance commands?
    – David
    Jun 17, 2016 at 22:40
  • 1
    @David Not for this case; if you would add them the output of echo would be exactly the same.
    – gertvdijk
    Jun 20, 2016 at 14:19

Silent install Java 6/7/8/9 using WebUpd8 team's PPA

sudo apt-get install -y python-software-properties debconf-utils
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-set-selections
sudo apt-get install -y oracle-java8-installer

@gertvdijk answer did not work with me on Ubuntu 14.04 & 14.10

  • 1
    works great on 16.04
    – pneumatics
    Sep 14, 2017 at 17:25
  • This is not working anymore Oct 20, 2017 at 15:22
  • @AhmedMostafa Can you let others know where you tried this. Dec 28, 2017 at 17:26
  • 1
    Works for oracle-java9-installer too. Mar 2, 2018 at 12:36
  • 1
    this work perfect with google/cloud-sdk based image
    – Xin Meng
    Apr 6, 2018 at 7:19

Supporting @gertvdijk answer is the description in the original blog post about webupd8's PPA.

Update 2: the installer now requires you accept the Oracle license before the installation begins. This is only required once. If for some reason you need the installation to be automated, you can run the following command to automatically accept the Oracle license:

sudo echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | \
sudo /usr/bin/debconf-set-selections
  • That's the line of magic I needed for my silent install of Oracle Java - thanks @Hosam Mar 26, 2014 at 3:23
  • You're welcome @Phantomwhale
    – Hosam Aly
    Mar 26, 2014 at 11:07
  • Am I mistaken, or there's a missing/extra " ` " character in your answer?
    – David
    Jun 17, 2016 at 22:39

I verified the following sentence work for me using docker ubuntu16.04LTS.

RUN apt-get install -y software-properties-common
RUN add-apt-repository ppa:webupd8team/java && apt-get update

RUN echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections
RUN echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 seen true" | debconf-set-selections

RUN apt-get install -y oracle-java8-installer
  • I tried it and it's not working. Oct 20, 2017 at 15:27
  • Confirmed working for me on docker-ce 18.05 on Kubuntu 18.04 :D installing in a i386/ubuntu:18.04 container.
    – BeepDog
    May 17, 2018 at 19:18

For a silent java install you can try open-jdk:

sudo apt-get install -y openjdk-7-jdk

Also try this for more open-jdk packages/extensions...

sudo apt-cache search openjdk

  • This solution worked great. sudo apt-get install -y openjdk-7-jdk
    – Layke
    Sep 19, 2012 at 17:17

Oracle java is no longer in the Ubuntu repos. http://www.omgubuntu.co.uk/2011/12/java-to-be-removed-from-ubuntu-uninstalled-from-user-machines

Here is how to install the Java JDK. How do I install Oracle Java JDK 7?

There should be a silent option available.


This is an excerpt from the Dockerfile I've used to successfully build a Debian based docker image:


RUN apt-get update \
    && apt-get upgrade \
    && apt-get install -y gnupg

RUN echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list
RUN echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
RUN apt-get update
RUN echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-set-selections
RUN apt-get install -y oracle-java8-installer \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* \
    && R CMD javareconf

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .