Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

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

aa05c5bb-55a1-4c63-b143-4f82c1e24bb7Nov 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

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 1 2015
Added on Nov 3 2015
1 comment
2,292 views