Finding Printers
Walter Vaughan
wvaughan at steelerubber.com
Thu Jul 5 14:41:04 UTC 2007
Can someone test this code on their box?
No matter how I try I cannot install a printer such that the JavaVM can find it.
If it does work, could you report what java version you used (diablo, ports) and
what version of 6 or 7, and how you installed the printer?
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
public class ListPrinters {
public static void main(String[] args) {
String sPrinterName = null;
PrintService[] services =
PrintServiceLookup.lookupPrintServices(null, null);
for (int i = 0; i < services.length; i++) {
PrintServiceAttribute attr =
services[i].getAttribute(PrinterName.class);
sPrinterName = ((PrinterName)attr).getValue();
System.out.println("Found printer: " + sPrinterName +
"\n");
}
System.out.println("Finshed\n");
}
}
The above code runs fine on sunJDK on Ubunutu box :( which means production will
have to be Ubuntu unless I can figure it out how to get the Java vm to recognize
installed printers.
Thanks for any help.
--
Walter
More information about the freebsd-java
mailing list