35

I'm searching for a possibility to get a list of installed printers. I'm using JDK 1.6 with a Windows operating system. Does anyone know a solution?

Thank you in advance.

3 Answers 3

76

Just wanted to add a little snippet:

import javax.print.*;

class Test {

    public static void main (String [] args)
    {
        PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null);
        System.out.println("Number of print services: " + printServices.length);

        for (PrintService printer : printServices)
            System.out.println("Printer: " + printer.getName()); 
    }
}
0
4

I haven't used this myself, but maybe javax.print.PrintServiceLookup contains what you are looking for.

0
0

Update for the newer Java packages

just modify:

import javax.print.PrintService;

import javax.print.PrintServiceLookup;

Not the answer you're looking for? Browse other questions tagged or ask your own question.