Installing Sun Java Non-interactively

In order to install the Sun Java packages on Debian or Ubuntu, you must first accept Sun’s license. Normally you are suppose to do this through an interactive menu. In order to get around this license prompt you can accept the license prior to installing the package.

Create a file containing the following lines:

sun-java5-jdk shared/accepted-sun-dlj-v1-1 select true
sun-java5-jre shared/accepted-sun-dlj-v1-1 select true
sun-java6-jdk shared/accepted-sun-dlj-v1-1 select true
sun-java6-jre shared/accepted-sun-dlj-v1-1 select true

Then run /usr/bin/debconf-set-selections as root. Now you should not be prompted to accept the license anymore.

References