471,337 Members | 1,132 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

PrintServiceLookup -- Not Detecting ANYTHING!

I am working on an install program, for another program that will need a
list of printers on a system. Originally I found the printers by doing

public PrintNames() {
String tName = "";
PrintService[] pServices = PrintServiceLookup.lookupPrintServices(null,
System.out.println("Service count: "+pServices.length);
cPrinter = new String[pServices.length];
for (int i = 0; i < pServices.length; i++) {
tName = pServices[i].getName();
System.out.println("Printer: "+tName);
cPrinter[i] = tName;

(Of course, this is part of the class PrintNames and I have other methods to
call to get the full list of printers, or a single printer -- cPrinter is a
String[] var, declared elsewhere.)

When I call lookupPrintServices(null, null), the Java Docs say that the
"null" params will avoid restrictions (like asking for something that will
print "text/plain", which could limit the list of printers). I've been
using this class for a while, and it's working fine on a Linux box AND a
Win2k box. The version of Java on the Linux box that is giving me a list
of printers is 1.4.1_02. The version on a Linux box where this DOESN'T
work is 1.4.2_01. (I would think, if anything, it wouldn't work on the
earlier version). I no longer have access to the Win2k system where it
worked, but that should be the same version as a Win2k system where it
doesn't work (1.4.2_01).

I've also tried this with different DocFlavors, but it makes no difference.

In short, I've tried this on 2 Linux boxen and 2 Win2k boxen. It worked on
1 Linux and 1 Win2k, but does not work at all on 1 Linux and 1 Win2k box.

What is going on? Am I doing something wrong, or is there a bug in
1.4.2_01? Is this worth using 1.5? (I haven't upgraded because I didn't
know if it would break anything I'm doing now.) How can I get a list of
printers on a box?

Thanks for any help!

Jul 17 '05 #1
0 1820

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by Jay | last post: by
6 posts views Thread by Matt Hawley | last post: by
8 posts views Thread by Matt Hawley | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.