如何开发Java软件以使用Epson reciept打印机打印收据?
答案 0 :(得分:18)
System.setProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_PROP_NAME, System.getenv("jposxml_path"));
我使用了系统环境变量,但您当然可以使用任何其他方式来指定路径。现在你准备好了!
示例:
POSPrinterControl113 printer = (jpos.POSPrinterControl113) new POSPrinter();
CashDrawerControl113 drawer = (CashDrawerControl113) new CashDrawer();
try {
printer.open("POSPrinter");
printer.claim(100);
printer.setDeviceEnabled(true);
} catch (Exception e) {
System.err.println("Printer deactivated " + e.getMessage());
printerdisabled = true;
drawerdisabled = true;
return;
}
try {
drawer.open("CashDrawer");
drawer.claim(100);
drawer.setDeviceEnabled(true);
} catch (Exception e) {
System.out.println("Cashdrawer deactivated: " + e.getMessage());
drawerdisabled = true;
return;
}