This is a small utility class that lists the printers as seen by Java.
This class is useful because in some cases, Java shows a different name for a printer than the one reported by the operating system.
import java.awt.print.PrinterJob; import javax.print.PrintService; public class ListPrinters { public static void main (String [] args) { // List printers PrintService [] ps = PrinterJob.lookupPrintServices(); for (int count = 0; count < ps.length; ++count) { System.out.println (ps [count].getName()); } } } |