Here you can find the source of lookupPrintServices()
public static PrintService[] lookupPrintServices()
//package com.java2s; /*//from w w w .j av a 2 s.c o m * Copyright (C) 2015 University of Oregon * * You may distribute under the terms of either the GNU General Public * License or the Apache License, as specified in the LICENSE file. * * For more information, see the LICENSE file. */ import javax.print.*; public class Main { private static boolean bWaitForPrinterServer = false; private static PrintService[] printSrvs = null; private static long lastQueryTime_all = 0; public static PrintService[] lookupPrintServices() { if (bWaitForPrinterServer) return printSrvs; bWaitForPrinterServer = true; if (printSrvs == null || printSrvs.length < 1) { long t = System.currentTimeMillis() / 1000; if ((t - lastQueryTime_all) < 120) { bWaitForPrinterServer = false; return printSrvs; } printSrvs = PrintServiceLookup.lookupPrintServices(null, null); lastQueryTime_all = System.currentTimeMillis() / 1000; } bWaitForPrinterServer = false; return printSrvs; } }