How to update the list of Windows printers in Java?

28 views Asked by At

I have a list of installed printers using this code:

import javax.print.*;

class Test {

    public static void main (String [] args)
    {
        PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null);
        System.out.println("Number of print services: " + printServices.length);

        for (PrintService printer : printServices)
            System.out.println("Printer: " + printer.getName()); 
    }
}

When a new printer is added the list is not updated untile the JVM restart, is there any way to update the list runtime?

I'm working with oracle JDK 17 in Windows 11 environment.

0

There are 0 answers