34

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.

Thomas
  • 8,357
  • 15
  • 45
  • 81

3 Answers3

75

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()); 
    }
}
Pedro Henriques
  • 1,708
  • 1
  • 14
  • 18
4

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

Ronald Blaschke
  • 4,036
  • 2
  • 22
  • 16
0

Update for the newer Java packages

just modify:

import javax.print.PrintService;

import javax.print.PrintServiceLookup;
Marko
  • 20,385
  • 13
  • 48
  • 64
alain
  • 1