Java Print Service: PrintServiceLookup.lookupPrintServices does not return network printers

If I run the JBoss application from the Windows command line, I can get a list of printers (including network printers).

If I run the JBoss application as a Windows service, I only get a list of printers that are directly connected to the machine. Network printers are not displayed.

Here is the Java code that I use to list printers:

PrintService[] printerServices = PrintServiceLookup.lookupPrintServices(null, null);

This is not a problem with permissions, because, according to our administrator, permissions are configured just fine.

Does anyone have a better explanation or is there a set of permissions that may be required to display network printers?

+3
source share
3 answers

You must start the Windows service as a domain user that has the appropriate permissions, and not as LocalUser.

You can also add network printers using the tcp / ip connection and the problem goes away.

+5
source

My colleague had the same problem just a few minutes ago, but on a REDHAT LINUX system. His server was rebooted, and the functionality of the printer only worked halfway; lp worked, cups worked, but no access to printers with Java. He found that localhost disappeared from the hosts file.

Its solution: add localhost to the hosts file (but since you are on Windows, this may not be your solution)

0
source

. , JRE, "" . , .

.: - > - > PDF → - > ( )

0

Source: https://habr.com/ru/post/1711126/


All Articles