CUP4J returns 'null' for printer status

448 Views Asked by At

I was trying to monitor state of network printer using CUPS4J that is connected to CUPS (v2.2.1). Though I have not used a real printer hardware, however I was able to connect ippserver (an IPP compatible printer simulator) as a network printer to CUPS in a Debian machine which has CUPS installed and configured.

When I try to print status of the printers I get 'null' value printed in the console instead of status, please help if you have any idea.

 public static void main(String[] args) throws Exception {
    CupsClient cupsClient = new CupsClient("xxxx", 631, "root");
    List<CupsPrinter> printers = cupsClient.getPrinters();

    printers.forEach(cupsPrinter -> {
        System.out.println(cupsPrinter.getName());
        System.out.println(cupsPrinter.getPrinterURL());
        System.out.println(cupsPrinter.getPrinterState());
        System.out.println(cupsPrinter.getPrinterStateMessage());
        System.out.println(cupsPrinter.getPrinterStateReasons());
        System.out.println(cupsPrinter.getState());
        System.out.println(cupsPrinter.getPrinterURL());
        System.out.println(cupsPrinter.getDeviceUri());
    });

output:

printer01
http://xxxx:631/printers/printer01
null
null
null
null
http://xxxx:631/printers/printer01
ipp://vxxx:8888/ipp/print

CUPS server output:

CUPS server output

0

There are 0 best solutions below