Finding Printers

Ronald Klop ronald-freebsd8 at klop.yi.org
Thu Jul 5 15:16:47 UTC 2007


On Thu, 05 Jul 2007 16:40:55 +0200, Walter Vaughan  
<wvaughan at steelerubber.com> wrote:

> 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
> _______________________________________________
> freebsd-java at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-java
> To unsubscribe, send any mail to "freebsd-java-unsubscribe at freebsd.org"

It works for me. I found 2 printers and I have 2 printers installed.
I'm using a recent CUPS on a recent FreeBSD 6.x-STABLE (i386) with a  
recent diablo-jdk.

-- 
  Ronald Klop
  Amsterdam, The Netherlands


More information about the freebsd-java mailing list