有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

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

配置:

  • OS:CentOS 5.4版
  • Linux:2.6.18-164。el5
  • Java:1.7.0\u 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

这就把我带到了太阳中的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) 个答案

  1. # 1 楼答案

    我不知道到底是什么解决了我的问题,但经过一个yum update它就不见了