lookupDefaultPrintService()不返回系统默认打印机

时间:2015-01-14 11:23:35

标签: java printing

配置:

  • 操作系统:CentOS版本5.4
  • Linux: 2.6.18-164.el5
  • Java: 1.7.0_25

您好,

我很难弄清楚为什么我的Java应用程序中的打印对话框使用了错误的打印机作为默认值。

lpstat -d返回'printer_ip0',printenv命令不返回LPDEST或PRINTER变量(根据我的理解,这些变量优先于系统默认设置)。

然而,每次我开始打印作业时,首先显示按字母顺序排列的第一台打印机(printer1),PrintServiceLookup.lookupDefaultPrintService().getName()给出相同的结果。

修改

启用IPP调试(System.setProperty("sun.print.ippdebug", "true"))时,我会收到以下日志:

CUPSPrinter>> libfound false
UnixPrintServiceLookup>> total# of printers = 2
CUPSPrinter>> libfound false
CUPSPrinter>> libfound false
CUPSPrinter>> libfound false
isRunning ? false
CUPSPrinter>> libfound false

这引导我进入sun.print包中的类CUPSPrinter(),特别是:

static {
   // load awt library to access native code
   java.security.AccessController.doPrivileged(
   new sun.security.action.LoadLibraryAction("awt"));
   libFound = initIDs();
   if (libFound) {
       cupsServer = getCupsServer();
       cupsPort = getCupsPort();
   }
}

不幸的是,它仍然没有告诉我为什么它无法访问本机代码。

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

我不确切知道是什么解决了我的问题,但在yum update之后它已经消失了!