*
The moose likes Java in General and the fly likes List of printers in the network Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "List of printers in the network " Watch "List of printers in the network " New topic
Author

List of printers in the network

Scan Dent
Greenhorn

Joined: Jul 18, 2005
Posts: 5
Is there any way of getting the list of printers in the network using JAVA.
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
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.
Scan Dent
Greenhorn

Joined: Jul 18, 2005
Posts: 5
I tried it. But unable to get the server location. Is there any way of getting that?

Regards
Prem
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
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.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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.


GenRocket - Experts at Building Test Data
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
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.
Scan Dent
Greenhorn

Joined: Jul 18, 2005
Posts: 5
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?

Regards
Prem
 
 
subject: List of printers in the network
 
Similar Threads
List of printers in the network
Windows shared printer
how many internet devices do you have?
printing in Linux
List of printers in the network