• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

List of printers in the network

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any way of getting the list of printers in the network using JAVA.
 
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried it. But unable to get the server location. Is there any way of getting that?

Regards
Prem
 
Stuart Gray
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Stuart Gray
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Catch Ernie! Catch the egg! And catch this tiny ad too:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic