Refresh printers in Java while application is running

后端 未结 4 920
心在旅途
心在旅途 2021-01-18 12:45

As the title says, I would like to refresh the printers that are registered in the settings of the computer while my Java application is running. Normally, I can use P

4条回答
  •  后悔当初
    2021-01-18 13:33

    I'm not sure what you were expecting. Here's the output for my Windows Vista laptop running Java 7.

    Number of servies found: 3
    --> Available Printer 0: Win32 Printer : PamFax
    --> Available Printer 1: Win32 Printer : Microsoft XPS Document Writer
    --> Available Printer 2: Win32 Printer : CutePDF Writer
    x
    Number of servies found: 3
    --> Available Printer 0: Win32 Printer : PamFax
    --> Available Printer 1: Win32 Printer : Microsoft XPS Document Writer
    --> Available Printer 2: Win32 Printer : CutePDF Writer
    

    Printer services don't change every 5 minutes, even on a shared network.

    Updated based on the comment:

    Your Java application will have to have to be stopped and started to get the updated list of printers.

    I guess I don't understand your environment. In the places I've worked, all of the printers have been defined on the network long before we ever wrote any code. Printer changes were rarely (i mean once a year) made.

提交回复
热议问题