Here you can find the source of getPrinterNames()
public static String[] getPrinterNames()
//package com.java2s; /**//from www .j av a 2 s .c o m * PrinterUtils.java * * Copyright (c) 1998 - 2008 BusinessTechnology, Ltd. All rights reserved * * This program is the proprietary and confidential information of BusinessTechnology, Ltd. and may * be used and disclosed only as authorized in a license agreement authorizing and controlling such * use and disclosure * * Millennium Business Suite Anywhere System. */ import javax.print.PrintService; import javax.print.PrintServiceLookup; public class Main { private static PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null); public static String[] getPrinterNames() { String[] result = new String[printServices.length]; for (int i = 0; i < printServices.length; i++) result[i] = printServices[i].getName(); return result; } }