Caros colegas boa Tarde.
Estou tentando listar [PrintService] as impressoras instaladas no Linux RHES 5.3 (CUPS V1.3.X), no entanto a classe sempre retorna vazia.
import javax.print.*;
public class ListPrinters {
public static String AvailablePrinters(){
String strList;
PrintService[] pservices =PrintServiceLookup.lookupPrintServices(null,null);
if (pservices.length > 0 )
strList = pservices[0].getName();
else
strList = "No printers found";
return strList;
}
public static String listprinters() throws Exception {
String listofprinters;
try {
SecurityManager sm = System.getSecurityManager();
if (sm != null) sm.checkPrintJobAccess();
}
catch (SecurityException ex) {
System.err.println("Sorry. Printing is not allowed.");
}
listofprinters = AvailablePrinters();
return listofprinters;
}
}
Aguardo respostas, obrigado.