Sunday, May 10, 2015

How to Check Printer Status Using Java


Open the Integrated Development Environment (IDE) program on your PC. Click 'File' and then 'Open' on the menu bar. Navigate to the Java application project file for which you want to enable print functions. Highlight the project file and click 'Open.'
Click 'File' or 'Create' on the menu tool bar. Scroll down to and click 'New/Class.' Wait for the IDE to load 'New Class' or 'Class' document window in the main project work area or screen. Click 'File/Save' on the menu bar. Save the class file as 'PrinterStatus.java.'
Enter the following code into the 'PrinterStatus.java' document window to define a new class object:public class PrinterStatus{public static void main(String[] args) { PrintService printer = PrintServiceLookup.lookupDefaultPrintService();AttributeSet att = printer.getAttributes();for (Attribute a : att.toArray()) {String attributeName;String attributeValue;attributeName = a.getName();attributeValue = att.get(a.getClass()).toString();System.out.println(attributeName + ' : ' + attributeValue);}}}
Click 'File' and then 'Save' on the menu tool bar. Close the 'PrinterStatus.java' class document window. Your Java web application can now process status requests for the main printer attached to the local PC.
Open another class or module from which to call, or initiate, printer status requests. Enter the following code at the point where the application should initiate the request: StatusofPrinterReport obj=new StatusofPrinterReport();obj.main()

3 comments:

  1. Always love your blog. you post really good information always. My team also helps to solve printers issue. So visit www.officejetprinters.com or want to talk our expert call toll free number tel:+1(800)6738163

    ReplyDelete
  2. Something different in you every post . you post really good information always. My team also helps to solve printers issue. So visit https://www.easyprintershelp.com or call toll free number tel:+1(800)6738163

    ReplyDelete
  3. When my printer gives me any error I come to read your blog and find my solution. Your all blogs are full with information. This website also related to printer solution so visit https://www.printercustomsupport.com/ or Contact us now! +1-800-673-8163

    ReplyDelete