Wednesday, April 21, 2010

Add a Java runtime to Ubuntu using update-alternatives

I just installed a Java JDK not using the package system. I wanted all users in this machine to be "aware" of this java runtime so the "java" command defaults to this implementation.

Ubuntu offers the "update-alternatives" utility to do this. This is both used to configure which of your (in this case) java implementations to use, but it can also be used to add a new one to the list. Here is the recipe (run as root, or sudo all commands):
# update-alternatives --install /usr/bin/java java \
  /opt/jdk1.6.0_14_x64/bin/java 100
# update-alternatives --config java

There is 1 program that provides 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           /opt/jdk1.6.0_14_x64/bin/java

Enter to keep the current selection[+], or type selection number: 1
# java -version
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode)
Note that in my case, since this was the only Java installed, there was no need to configure it via --config. I just ran it to make sure this one was the current choice. Also, if you do not want the interactive prompt you can just run:
sudo update-alternatives --set java /opt/jdk1.6.0_14_x64/bin/java

Thursday, April 8, 2010

Skype video on Ubuntu 9.10

I had solved this long ago but reappeared in my relatively new Ubuntu 9.10 install: Skype (2.1.x) does not show video from my webcam; a usb Logitech QuickCam Pro 5000:
$ lsusb
Bus 001 Device 002: ID 046d:08c5 Logitech, Inc. QuickCam Pro 5000
I tried a few things and it turned out that the solution was something I had found that was supposed to aim a problem with 64bit systems and 32bit libraries. One needs to set the variable LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so. (That's the path in my Ubuntu, it may vary in other system).

Then, to launch Skype, I am using a small script:
#!/bin/bash
LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so skype
for which I also created a menu icon.