[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 453
  • Last Modified:

Listing Printers connected to the system using java print service

Hi i m using PrintServiceLookup.lookupPrintServices() to list the printers present in the system in my web application.

But i see that the list does not change in my web page when i connect new printer to the system unless i restart the server.

0
robin_smith123
Asked:
robin_smith123
  • 2
  • 2
1 Solution
 
objectsCommented:
try the following to refresh the list

    public void refresh() {
        try {
            Class[] classes = PrintServiceLookup.class.getDeclaredClasses();
            for (Class clazz : classes)
                if ("javax.print.PrintServiceLookup$Services".equals(clazz.getName())) {
                    AppContext.getAppContext().remove(clazz);
                    break;
                }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

0
 
robin_smith123Author Commented:
AppContext.getAppContext().remove(clazz)
wts Appcontext and how to get that in my code
0
 
objectsCommented:
import sun.awt.AppConext;

0
 
robin_smith123Author Commented:
thanx!!!!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now