Thomas
Thomas

Reputation: 10135

How do I get a list of installed printers?

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.

Upvotes: 37

Views: 32694

Answers (3)

alain
alain

Reputation: 1

Update for the newer Java packages

just modify:

import javax.print.PrintService;

import javax.print.PrintServiceLookup;

Upvotes: 0

Pedro Henriques
Pedro Henriques

Reputation: 1736

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()); 
    }
}

Upvotes: 77

Ronald Blaschke
Ronald Blaschke

Reputation: 4184

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

Upvotes: 4

Related Questions