HOWTO: Install Sun’s JDK on Ubuntu (without the Command Line)

The Java Devel­op­ment Kit (JDK), which is required to write appli­ca­tions in Java, is not included by default in the Ubuntu Linux OS. Var­i­ous guides (such as this one) will give you a suc­cinct set of com­mands to run from the ter­mi­nal to down­load and install Sun’s (now Oracle’s) offi­cial JDK. But, prob­a­bly because it’s harder to explain, none show you the slightly more user-friendly point-and-click way of doing it. Well, this page does.

  1. Open the Ubuntu Soft­ware Cen­tre, located in your Appli­ca­tions menu.  The app will open, but no mat­ter what you search for, you won’t get Sun’s JDK.  This is because it has been moved to Ubuntu’s “Part­ner” repos­i­tory, which is not enabled by default.  We will now enable it.
  2. Go to the Edit menu, and click Soft­ware Sources…
    The Ubuntu Software Centre's Edit menu
  3. You’ll be prompted to enter your pass­word, so do that:
    Password dialog
  4. In the box that appears, go to the Other Soft­ware tab.  You should see an entry on the list labelled “Canon­i­cal Part­ners”.  Check the box at the left of that entry, then click Close.
    Software Sources window
  5. You will now be returned to the main Ubuntu Soft­ware Cen­tre win­dow, where an “In Progress” indi­ca­tor will appear for a minute or so.  Once com­plete, you can search for “JDK” and… it still won’t show it to you.
  6. As the JDK is not some­thing that most home users want, there’s an extra obsta­cle in the way — you must ask the Soft­ware Cen­tre to show you “tech­ni­cal items”.  There’s a link at the bot­tom of the win­dow for this:
    Show Technical Items
  7. You should now have an exten­sive list of pack­ages that fea­ture the let­ters “JDK”.  You want to pick the one with the pack­age name sun-java6-jdk.  Click it, then click the Install but­ton on the right.
    Ubuntu Software Centre window with sun-java6-jre selected
  8. The JDK will now be down­loaded and installed.  Within a cou­ple of min­utes, this will be com­plete; the Install but­ton will change to say Remove and the icon next to sun-java6-jre will show a green tick.

Sun’s JDK is now installed.  You can now search for and install Sun’s JRE, and any­thing else you might want from the Part­ner repos­i­tory.  The appro­pri­ate loca­tions have been added to the sys­tem path auto­mat­i­cally, but if you should need to find the JDK files man­u­ally, they’re in /usr/lib/jvm/java-6-sun-1.6.0.26 (the last sec­tion of the path may change if the lat­est JDK ver­sion is later than it was when this arti­cle was written).

The UI of Least Resistance

I was work­ing up to a blog post on Ubuntu’s new “Unity” inter­face a cou­ple of days ago, but repeat­edly stalled when it came to mak­ing a point. The only point I could come up with was essen­tially just “I don’t like this”, which isn’t the great­est of sub­jects for a blog post — to say noth­ing of the hun­dreds who have trod­den that ter­ri­tory before me.

Ubuntu's Unity interface

Ubuntu’s Unity inter­face (image credit: webupd8.org)

It’s a fairly bold new direc­tion for Ubuntu’s UI, and the first time their default inter­face has really diverged from what the upstream GNOME project pro­vides. Now I don’t like it for a num­ber of rea­sons: it’s slow, it doesn’t pro­vide some basic func­tion­al­ity, other func­tion­al­ity is really well hid­den (Go on, re-order your icons. Try it.) and it’s got an “our way or noth­ing” approach to han­dling workspaces.

On one hand, as a soft­ware guy whose main spe­cial­i­sa­tion is user inter­face design, I under­stand the urge to try new UI par­a­digms as often as pos­si­ble, on the grounds that sooner or later you’ll dis­cover some­thing that really is bet­ter than what you cur­rently have. On the other hand, I qui­etly despair at how far off that “some­thing bet­ter” seems.

Take, for exam­ple, me. I’m a UX per­son, and a per­fec­tion­ist when it comes to inter­faces. I’m irri­tated by slightly-wrong fonts and icons a cou­ple of pix­els out of align­ment. I love new things, new ways of organ­is­ing and dis­play­ing data. I’m big on aug­mented real­ity. And my desk­top looks like this:

Bare XFCE Desktop

Now I think that’s aes­thet­i­cally pleas­ing, but in terms of func­tion­al­ity, it resem­bles noth­ing quite so much as:

Windows 95 Desktop

Yeah, that.

The only notable excep­tion is GNOME-Do (think Launchy on Win­dows or Quick­sil­ver on OS X), which I use exclu­sively for launch­ing apps. The main menu, lower left, only gets used if I for­get the name of some­thing. Aside from that, I’m using my com­puter in exactly the same way I was 16 years ago.

The rea­son for that, as far as I can tell, is that it is the UI of least resis­tance. In six­teen years, prob­a­bly 99% of my computer-using time has involved an inter­face that’s very sim­i­lar to that one. Sure, there are cer­tainly bet­ter UIs out there. Maybe from an objec­tive point of view, Unity is one of them. But for more than half of my life, my brain has been slowly opti­mis­ing itself for the Win­dows 95 style interface.

To become the “next big thing” in desk­top UI, a new par­a­digm must not only be bet­ter than what came before, it must be so much bet­ter that our brains don’t mind los­ing half a lifetime’s worth of learning.

That’s a mile­stone I haven’t seen reached lately on the desk­top, and a fear we may not see it reached before “the desk­top” stops being a thing.

HOWTO: Use an XBox 360 Dance Mat on Ubuntu Karmic

Nor­mal XBox 360 wired con­trollers are sup­ported out of the box on Ubuntu Karmic (9.10). How­ever, it seems that dance mats such as the one that comes bun­dled with Danc­ing Stage Uni­verse behave a lit­tle dif­fer­ently. Here’s how I got mine to work.

This HOWTO is in the pub­lic domain. You are free to re-post it wher­ever and how­ever you like, though a link back here would be appreciated.

Be warned, this is not for the faint of heart — we will be spend­ing most of our time in a ter­mi­nal win­dow, and we’ll be com­pil­ing dri­vers our­selves. Read the instruc­tions care­fully, and fol­low what I did line by line. If you have prob­lems, leave a com­ment and I’ll see if I can help you out. Run­ning com­mands as the root user is poten­tially dan­ger­ous; I am not respon­si­ble if your com­puter is dam­aged by incor­rectly fol­low­ing these instructions.

First of all, check that you have the same device as I do. If not, pro­ceed only with cau­tion! To find out, plug your dance mat into a USB port, open up a ter­mi­nal win­dow and run

lsusb

You should see a line which looks like:

Bus 002 Device 002: ID 12ab:0004 Honey Bee Electronic International Ltd.

Your ‘Bus’ and ‘Device’ num­bers will prob­a­bly be dif­fer­ent, but the rest of the line should be the same.

The xpad dri­ver, which is already baked into the ker­nel, does not work for these dance mats. We will have to instead install xbox­drv, which does sup­port dance mats.

The first thing we need to do is down­load the source code for xbox­drv. Their web­site pro­vides down­loads of var­i­ous ver­sions (at time of writ­ing, the lat­est was 0.4.10), but I chose to grab the very lat­est code from their git repos­i­tory. To do that, first install git if you don’t already have it:

sudo apt-get install git-core

Then find a space to down­load xboxdrv to — I just chose my home direc­tory, which should be the loca­tion you’re at when you first run the ter­mi­nal any­way. Down­load their lat­est source using git, then go into the down­loaded directory:

git clone git://github.com/Grumbel/xboxdrv.git
cd xboxdrv

Now you’ll need to com­pile the dri­ver from the source code you’ve just down­loaded. These fol­low­ing instruc­tions are largely from the README file included with xboxdrv. You’ll need a bunch of things installed so that you can com­pile the code. To make sure you have every­thing, run:

sudo apt-get install g++ libboost1.40-dev libboost-thread1.40-dev scons libusb-dev libx11-dev x11proto-core-dev python-dbus

Now com­pile by sim­ply running:

scons

Make a cup of tea, this will take a few minutes.

Assum­ing you don’t see any errors, you now have a dri­ver that will sup­port the dance mat. How­ever, this is a ‘user-space’ dri­ver, which means we don’t actu­ally bake it into the ker­nel — instead, we need to make sure that the ker­nel sup­ports user-space input dri­vers, then we run xboxdrv as if it were a nor­mal application.

First of all, though, we should check it’s actu­ally work­ing. To start with, we’ll remove the xpad dri­ver from the ker­nel, and add the user-space dri­ver sup­port. Note that if you have any other joy­sticks, remov­ing xpad could stop them work­ing. I’m not sure if there’s any way around this at the moment. Run the fol­low­ing commands:

sudo rmmod xpad
sudo modprobe uinput
sudo modprobe joydev

Now we can run xboxdrv and check it’s work­ing. Type:

sudo ./xboxdrv

You should see some­thing like the following:

xboxdrv 0.4.8
Copyright (C) 2008 Ingo Ruhnke <grumbel@gmx.de>
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
 
USB Device:        002:002
Controller:        "DDR Universe 2 Mat" (idVendor: 0x12ab, idProduct: 0x0004)
Controller Type:   Xbox360
Deadzone:          0
Trigger Deadzone:  0
Rumble Debug:      off
Rumble Speed:      left: -1 right: -1
LED Status:        auto
Square Axis:       no
ButtonMap:         none
AxisMap:           none
RelativeAxisMap:   none
AutoFireMap:       none
RumbleGain:        255
ForceFeedback:     disabled
 
Starting with uinput... Error: /dev/input/uinput: No such file or directory
done
 
Your Xbox/Xbox360 controller should now be available as:
  /dev/input/js0
  /dev/input/event7
 
Press Ctrl-c to quit
 
X1:     0 Y1:     0  X2:     0 Y2:     0  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0
TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:0 RB:0  LT:  0 RT:  0

(You can ignore the “Error: /dev/input/uinput: No such file or directory” line if it appears on your screen, it doesn’t seem to affect xboxdrv at all.)

Press some of the pads on your dance mat. You should see extra lines appear­ing at the end indi­cat­ing the but­tons that have been pressed. The arrows on the mat match up to D-pad direc­tions, so for exam­ple if you press Down, you should see dd:1 on the line that appears.

Once you’re sat­is­fied that it’s work­ing, hit Ctrl+C to quit.

Before we’re fin­ished, we need to make those changes to the ker­nel mod­ules per­ma­nent. To do this, run:

sudo -i
echo "blacklist xpad" >> /etc/modprobe.d/blacklist.conf
echo "uinput" >> /etc/modules
echo "joydev" >> /etc/modules
exit

You can now reboot if you want to, and all your ker­nel mod­ule changes will stick.

There’s one more step. At the moment before using your dance mat, you’ll still have to run xboxdrv man­u­ally. We can fix this with an ‘init script’ that will run xboxdrv auto­mat­i­cally on startup.

First, let’s put xboxdrv some­where sen­si­ble on your filesys­tem, rather than in your home directory:

sudo mkdir /usr/local/bin/xboxdrv
sudo cp xboxdrv /usr/local/bin/xboxdrv/xboxdrv
sudo cp tools/xboxdrv-daemon.py /usr/local/bin/xboxdrv/xboxdrv-daemon.py

Now we’ll set up the init script. The script itself is a few dozen lines, so rather than past­ing it here, here’s a down­load link instead: xbox­drv init script. Down­load this, then copy it to /etc/init.d. That requires root access, so from your ter­mi­nal, run the fol­low­ing to down­load the above file and put it in the right place:

cd ~
wget http://www.onlydreaming.net/files/xboxdrv
sudo mv xboxdrv /etc/init.d/xboxdrv

Now we have to make sure that’s exe­cutable and that it runs on startup:

sudo chmod +x /etc/init.d/xboxdrv
sudo update-rc.d xboxdrv start 51 S .

(don’t for­get the dot on the end!)

Aaaand at long last, you should be done. Reboot, and your dance mat should work prop­erly with no extra con­fig­u­ra­tion. If you’re using Step­Ma­nia, remem­ber to map the mat’s con­trols before play­ing. If you’ve not drunk that cup of tea yet, it’s prob­a­bly cold!

If you’re look­ing for a sim­i­lar guide for Open­SuSE, I’ve just dis­cov­ered this post which is sim­i­lar to the post you’re read­ing, but with OpenSuSE-specific init script instructions.

All Bugs Are Shallow… Except This One

In his essay “The Cathe­dral and the Bazaar”, Eric S. Ray­mond coins the phrase “given enough eye­balls, all bugs are shal­low” — mean­ing that with enough testers and enough pro­gram­mers, it is pos­si­ble to diag­nose and fix any soft­ware bug.

So why can’t my com­puter sus­pend and resume properly?

The con­cept of ‘sus­pend’ — or ‘sleep’, or ‘standby’ — mode, whereby the com­puter dumps its inter­nal state to RAM then enters a low-power state with its proces­sor and other hard­ware turned off, is not new. The ACPI stan­dard has been kick­ing around for 14 years now, a very long time com­pared to the life cycle of an oper­at­ing sys­tem. These days, with lap­top use on the rise, it’s a very com­mon thing for users to want to do. And yet resum­ing from sus­pend is still hit-and-miss.

Why do I find it more reli­able in Ubuntu than open­SUSE for the same base ker­nel? Why does GNOME fare bet­ter than KDE? Why does my WiFi some­times not come back? Why, with Microsoft’s mil­lion– if not billion-dollar oper­at­ing sys­tem bud­gets, with Intel and AMD and nVidia’s decades’ of dri­ver expe­ri­ence, is sus­pend and resume still fre­quently an issue even on Windows?

Only Apple, with its closed hard­ware / soft­ware ecosys­tem, seems to have cracked it.

I’d hate to think of that as the only way to a bug-free exis­tence — I’m very fond of the idea of an open ecosys­tem where I can run what­ever soft­ware I want on what­ever hard­ware I want. But I’m wor­ried. Is the range of (IBM-compatible, ACPI-supporting) hard­ware out there just too diverse and too widely dif­fer­ent in its sup­port for suspend-and-resume? Is it just infea­si­ble for soft­ware to per­fectly imple­ment it on all devices?

Has hard­ware cre­ated the one soft­ware bug that, for any rea­son­able num­ber of eye­balls, isn’t shal­low?