I am able to get the name of printer which I had installed previously on my PC.But now its not physically connected to my pc. How should I check it first before moving to Print(
You can use PrinterState
attribute if it is supported by your printer.
Something like this:
PrintServiceAttributeSet printServiceAttributes = selectedService.getAttributes();
PrinterState printerState = (PrinterState) printServiceAttributes.get(PrinterState.class);
if (printerState != null){
System.out.println(printerName + " is online");
}
else {
System.out.println(printerName + " is offline");
}