You can certainly use Java to find a list of all currently configured/installed printers (i.e. only those which can be seen in the Control Panel in Windows). Check out the lookupPrintServices() method of the javax.print.PrintServiceLookup class. Also check out the DocFlavor and AttributeSet classes.
Sorry I couldn't be more help but I don't have much recent experience in this area.
Joined: Jul 18, 2005
I tried it. But unable to get the server location. Is there any way of getting that?
Joined: Apr 21, 2005
I'm not sure I understand what you mean by the 'server location'. Heres my understanding - this is based on Windows which I'm going to assume you're using for now (for no particular reason).
For any printer - whether local or networked - to be used, its drivers have to be installed. You do this using the Add Printers function in the control panel, and networked and local printers are basically shown in the same way. So even if a printer is connected to SERVER1, I must 'install' (i.e. copy the drivers for) that printer on my local machine before I can use it.
My understanding is that the Java print functionality will only list those printers which have already been installed by Windows and are visible in the Control Panel. In other words, I don't think it is possible to discover new printers using the Java API, since that would require the OS to install some drivers for the new device.
What he is wanting to do is use java to list all available printers on the network. You don't have to install drivers to discover printers on the network. If you look at the domain tree or a workgroup you can see all shared printers in the network. This is basically what he wants to do. Printers give off some signature on the network that says "Hey, I'm a printer". What that signature is and how to resolve it using Java, I don't know. But for future people trying to help, this is what I believe the question is about.
Right, yes sorry. I don't know how I missed that the first two times:
It must surely be a JNI/Windows API solution then, since the method to do this will almost certainly be platform dependant.
Joined: Jul 18, 2005
I agree with you even if we can find the network printers it may not be of much help if the corresponding printer drivers are not installed on that machine. Is it possible to get the list of printers that were installed in a particular machine? What i need is executing the 'PrintServiceLookup.lookupPrintServices' so that it returns the list of printers on a particular machine?