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@example.com> 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
license=oracle-license-v1-1 # snip db_get shared/accepted-$license if [ "$RET" = "true" ]; then echo "$license license has already been accepted" >&2 exit 0 fi
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
apt-get as it gives you the opportunity to set other than default settings on installation times.