Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

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.

share|improve this answer
    
Just what I was looking for, thanks! –  chrisbunney Oct 10 '11 at 11:06
add comment

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

share|improve this answer
add comment

My first thought is using a package for your native distribution, as Java is compiled anyway there is not much advantage unless you need a very particular version. If that were the case, you could also create your own package.

I typically redirect STDIN. For example:

/command/to/run <<_EOF
answer1
answer2
_EOF

For particularly tricky things an alternative to that is expect.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.