Java Printing Fix for Linux

Apparently, there’s a bug in Java where people using newer version of CUPS cannot print (can’t even display the print dialog) due to a null pointer exception and this is actually a known bug. So, how do we fix this? For people who use Gnome, you can refer to this page

However, for people who uses non desktop environment such as Fluxbox, Openbox and etc (Gnome and KDE user can use these steps too), you can fix it by editing your CUPS printers configuration file. You can get edit the file at /etc/cups/printers.conf

<DefaultPrinter Printer>
# Printer configuration file for CUPS v1.3.7
# Written by cupsd on 2008-09-08 11:24
Option orientation-requested 3

Make sure you Option orientation-requested 3 to every configuration for every printer you’ve installed. If you cannot find the file, it’s possible that you haven’t configured any printer yet.

This fix is simply to make sure CUPS will provide a page orientation setting to Java.

The exception:

Caused by: java.lang.NullPointerException: null attribute
        at sun.print.IPPPrintService.isAttributeValueSupported(
        at sun.print.ServiceDialog$OrientationPanel.updateInfo(
        at sun.print.ServiceDialog$PageSetupPanel.updateInfo(
        at sun.print.ServiceDialog.updatePanels(
        at sun.print.ServiceDialog.initPrintDialog(
        at sun.print.ServiceDialog.(
        at javax.print.ServiceUI.printDialog(
        at sun.print.RasterPrinterJob.printDialog(
        at sun.print.PSPrinterJob.printDialog(</code>

Please refer to some of the discussions here:

FYI, you need to restart your CUPS after editing the configuration (Thanks to Brandon Bell).

Written by Amree Zaid

Powered by Jekyll. Get the source at Github. Design copied from Sam Vermette.