If I remember correctly, the “accept license” bit can be set explicitly, since the conclusion from the installation process says that the license has already been accepted at a later stage. Therefore, check out the Ubuntu package and find out how to do it.
I would not go on OpenJDK, since I do not think that he passed TCK.
EDIT: , :
DEBIAN_FRONTEND=noninteractive apt-get install -y java5-sun-jre || :
debconf 'echo SET shared/accepted-sun-dlj-v1-1 true; echo $(read) >&2'
apt-get install -y java5-sun-jre
http://ubuntuforums.org/showpost.php?p=6752243&postcount=9