Here you can find the source of getDefaultPrinterName()
public static String getDefaultPrinterName()
//package com.java2s; //License from project: Open Source License import javax.print.PrintServiceLookup; public class Main { public static String getDefaultPrinterName() { if (PrintServiceLookup.lookupDefaultPrintService() != null) { return PrintServiceLookup.lookupDefaultPrintService().getName(); }/*w w w .j a v a 2s.c o m*/ return ""; // no default printer specified } }