When I attempt to install a package on my ubuntu(10.10) server on amazon ec2 with update-alternatives" for the JRE, apt-get doesn't respond anymore.

I've been waiting now for 20 minutes on this hang with this line of text:

   update-alternatives: using /usr/lib/jvm/java-6-openjdk/jre/lib/jexec to provide /usr/bin/jexec (jexec) in auto mode.

And if I try to stop it and restart the system. the next time I use apt-get or aptitude in any way it gives me

E: dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem.

In which the command doesn't fix the problem leaving me with a broken apt-get.


To fix dpkg: http://lydonchandra.com/content/failure-installing-jre-java-runtime-env-ec2-ubuntu-10

I am having the same problem too, ami-00067852 ap-southeast-1a zone. What on earth is going on?


There is a way to get your dpkg running again. Alas, I still don't know how to install jre on my debian, since exactly the same thing happens each time jre install is attempted.

In a nutshell, you need to purge incompletely installed packages, after you have killed dpkg and java processes (java process consumed 100% cpu on my box). Then your dpkg should be operational again.

Detailed instructions follow. These may serve as a guide for someone else with same issues.

  1. open up another console/ssh session, and kill java and dpkg processes (use ps -A |grep -E "(java|dpkg)" to find them)
  2. run dpkg -l |grep -v -E "^ii" - this will list all packages that are either not in perfectly installed state; either incompletely installed, or that have config files remaining behind them after they have been uninstalled (or some other variant). You can tell them apart by value in first column. (rc = removed & conf-files; iU = install & unpacked). See listing header (dpkg -l | head for detailed meanings).
  3. run dpkg -P package_name [package_name2] [package_name3 ...] in order to purge those incomplete packages. Personally, I have removed all listed packages (as they were all related to broken jre install), and dpkg was running afterwards.
  4. optionally, reboot your system to get rid of that defunct java process (it kept hanging in process list after I killed it)

Update: after some more research, turns out that this bug is exclusively related to running a 32-bit t1.micro instance of debian-based-distro AMI on Amazon EC2.

A solution that worked for me (credited to DanielDaniel - thanks, @Yuval), is to:

  1. stop (or halt) a running instance (prior to which you need to make sure that it will not terminate on halt)
  2. change instance type to m1.small (either using EC2 console, or using CLI)
  3. start an instance
  4. install java package that you want
  5. stop an instance (again)
  6. change instance type back to t1.micro
  7. start an instance (again)

This will cost you probably only as much as it costs to run m1.small instance for 1 hour. Should be up and running in no time.

Update 2: after going through all troubles, it appears that Java won't work on t1.micro instance at all. Running anything java-based will have same effect on your system as running installation of jre/jdk. So, in order to use java on t1.micro either use some other non-debian-based distro (however, I'm not 100% sure it would work, either), or upgrade instance to m1.small or better.

Update 3: as of 08/11/2011, issue has not resolved. See https://bugs.launchpad.net/ubuntu/+source/linux-ec2/+bug/634487 for further updates. Right now it's up to Amazon to review proposed patch... Basically, they'll fix it when they do...

  • any updates on how to resolve this? – EquinoX Aug 10 '11 at 23:20
  • @EquinoX: unfortunately, no, not yet. See my updated answer. – mr.b Aug 11 '11 at 19:29

Did you ran dpkg --configure -a as you have been told? If yes what did you get as a result?


Then run: strace -s100 -f -o /tmp/debug.out dpkg --configure -a wait a few minutes then upload the file somewhere. Or attach the lets say last 200 lines here.


The file named /tmp/debug.out is needed. The output on the console does not change.

  • When I run the command it provides, It hangs once again at this point and I end up stuck. I've gone through 2 instances like this. Processing triggers for libc-bin ... ldconfig deferred processing now taking place Setting up openjdk-6-jre-headless (6b20-1.9-0ubuntu1) ... – Noel Nov 14 '10 at 23:40
  • It has been holding here for an hour and a half now. After I used your command this was/still is the text I see. – Noel Nov 16 '10 at 2:39
  • ubuntu@domU-12-31-39-14-ED-D3:~$ sudo strace -s100 -f -o /tmp/debug.out dpkg --configure -a Setting up openjdk-6-jre-headless (6b20-1.9-0ubuntu1) ... – Noel Nov 16 '10 at 3:40

I had the 32-bit ami-ccf405a5 was causing me problems with jre. I used a 64-bit ami then (ami-cef405a7) and it solved my problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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