添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

For appeals, questions and feedback about Oracle Forums, please email [email protected] . Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Looking up print services in Java 8 returns null; Works fine in Java 7

aa05c5bb-55a1-4c63-b143-4f82c1e24bb7 Nov 3 2015 — edited Nov 3 2015

I'm running RHEL 6.4 and trying to use Java to lookup print services:

PrinterService[] services = PrinterJob.lookupPrintServices();

This works great in Java 7. It returns the default printer on my system.

When I run the same thing in Java 8, I get null.

I also tried:

PrintService service = PrintServiceLookup.lookupDefaultPrintService();

Again, in Java 7, it returns my default printer. In Java 8, it returns null.

I then tried using the following lookup command:

PrinterService[] services = PrinterServiceLookup.lookupPrintServices(null, null);

Again, in Java 7, this returns my default printer.

In Java 8, it actually returns the same printer (i.e. same printer name), but when I run getSupportedDocFlavors() on the returned PrintService, it's null. Because of this, I get an exception while trying to print:

java.awt.print.PrinterException: Not a 2D print service: IPP Printer : printer

I would really like to know how I can get Java 8 to recognize my printer the same way that Java 7 does.

Another detail: If I ssh to my printer server and open up /etc/cups/client.conf, and change ServerName to "localhost" (instead of the printer server IP), then Java 8 finds it. So it seems like Java 8 is having trouble finding it over the network.

Does anybody have any ideas on how to solve this?

Thanks,

John