Monday, June 04, 2007

CUPS + Java Printing Aaargh

After being able to print fine from Java in Ubuntu Edgy, I upgraded to Feisty and found that Java was now unable to detect printers using PrintServiceLookup.lookupPrintServices(null, null);

A couple of frustrating hours later, I found this article on the CUPS website explaining the problem (a Java bug, caused by updating to CUPS 1.2). The fix is:

In cupsd.conf, comment out:

#Listen /var/run/cups/cups.sock

leave uncommented:

Listen localhost:631

Another weird Java / CUPS problem I came across was that some Java versions will apparently refuse to print to printers with a - or an @ in the printer name. This wasn't my problem, but it's probably best avoiding these anyway.