By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,040 Members | 1,815 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,040 IT Pros & Developers. It's quick & easy.

PrintServiceLookup -- Not Detecting ANYTHING!

P: n/a
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
this:

public PrintNames() {
String tName = "";
PrintService[] pServices = PrintServiceLookup.lookupPrintServices(null,
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;
}
return;
}

(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!

Hal
Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.