Scripted install of Sun Java JDK on Ubuntu 9.04

We are trying to script the install of the sun jdk on Ubuntu 9.04 and have it automatically accept the license agreement. I have seen something around the net about creating a file that the package looks for, but none of them were complete. Does anyone know how to get this working?


Solution 1:

The Sun Java packages keep track of whether you've agreed to the license agreement using Debconf. You can bypass that check by running

echo "sun-java6-bin shared/accepted-sun-dlj-v1-1 boolean true" | debconf-set-selections

before installing sun-java6-jre or whatever Sun Java package you want.

Solution 2:

I've tested this in ubuntu 10.04 and works fine:

#!/bin/sh

DEBIAN_FRONTEND=noninteractive

echo "sun-java6-bin shared/accepted-sun-dlj-v1-1 boolean true" | debconf-set-selections

echo "sun-java6-jre shared/accepted-sun-dlj-v1-1 boolean true" | debconf-set-selections

apt-get install -y sun-java6-bin