Java POS打印机错误

我是Java的新手,我正在使用java开发POS应用程序。

我为这个项目买了一台爱普生POS打印机。 打印机型号为EPSON TM-U220.

我已经安装了JavaPos和我的代码片段,如下所示。 但是在运行时我得到了这个错误。

感谢是否有人可以帮我解决这个问题。


 run: jpos.JposException: Service does not exist in loaded JCL registry StarReceiptTest finished. at jpos.loader.simple.SimpleServiceManager.createConnection(SimpleServiceManager.java:179) at jpos.loader.JposServiceLoader.findService(JposServiceLoader.java:154) at jpos.BaseJposControl.open(BaseJposControl.java:481) at StarReceiptTest.main(StarReceiptTest.java:54) BUILD SUCCESSFUL (total time: 1 second) 

 import jpos.JposConst; import jpos.JposException; import jpos.POSPrinter; import jpos.POSPrinterConst; import jpos.util.JposPropertiesConst; public class StarReceiptTest { public static void main(String[] args){ /* If you want to place the jpos.xml file elsewhere on your local file system then uncomment the following line and specify the full path to jpos.xml. If you want to place the jpos.xml file on a webserver for access over the internet then uncomment the second System.setProperty line below and specify the full URL to jpos.xml. */ //C:\Users\Udayanga\Documents\NetBeansProjects\Jpos_Sample\src //System.setProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_PROP_NAME, "jpos.xml"); System.setProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_PROP_NAME, "C:\\Users\\Udayanga\\Documents\\NetBeansProjects\\Jpos_Sample\\src\\jpos.xml"); //System.setProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_URL_PROP_NAME, "http://sofzh.miximages.com/java/ print an image file try { printer.printBitmap(POSPrinterConst.PTR_S_RECEIPT, star.gif", POSPrinterConst.PTR_BM_ASIS, POSPrinterConst.PTR_BM_CENTER); } catch (JposException e) { if (e.getErrorCode () != JposConst.JPOS_E_NOEXIST) { // error other than file not exist - propogate it throw e; } // image file not found - ignore this error & proceed } } // call printNormal repeatedly to generate out receipt // the following JavaPOS-POSPrinter control code sequences are used here // ESC + "|cA" -> center alignment // ESC + "|4C" -> double high double wide character printing // ESC + "|bC" -> bold character printing // ESC + "|uC" -> underline character printing // ESC + "|rA" -> right alignment printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, ESC + "|cA" + ESC + "|4C" + ESC + "|bC" + "Star Grocer" + LF); printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, ESC + "|cA" + ESC + "|bC" + "Shizuoka, Japan" + LF); printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, ESC + "|cA" + ESC + "|bC" + "054-555-5555" + LF); printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, ESC + "|uC" + "Qnty Unit Tx Description" + SPACES.substring(0, printer.getRecLineChars() - "Qnty Unit Tx Description".length()) + LF); printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, " 1 830 Soba Noodles" + LF); printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, " 1 180 Daikon Radish" + LF); printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, " 1 350 Shouyu Soy Sauce" + LF); printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, " 1 80 Negi Green Onions" + LF); printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, " 1 100 Wasabi Horse Radish" + LF); printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, " 2 200 Tx Hashi Chop Sticks" + LF); printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, LF); printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, ESC + "|rA" + "Subtotal: 2160" + LF); printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, ESC + "|rA" + "Tax: 24" + LF); printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, ESC + "|rA" + ESC + "|bC" + "Total: 2184" + LF); printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, ESC + "|rA" + "Tender: 2200" + LF); printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, ESC + "|rA" + ESC + "|bC" + "Change: 16" + LF); printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, LF); if (printer.getCapRecBarCode() == true) { // print a Code 3 of 9 barcode with the data "123456789012" encoded // the 10 * 100, 60 * 100 parameters below specify the barcode's height and width // in the metric map mode (1cm tall, 6cm wide) printer.printBarCode(POSPrinterConst.PTR_S_RECEIPT, "123456789012", POSPrinterConst.PTR_BCS_Code39, 10 * 100, 60 * 100, POSPrinterConst.PTR_BC_CENTER, POSPrinterConst.PTR_BC_TEXT_BELOW); } printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, ESC + "|cA" + ESC + "|4C" + ESC + "|bC" + "Thank you" + LF); // the ESC + "|100fP" control code causes the printer to execute a paper cut // after feeding to the cutter position printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, ESC + "|100fP"); // terminate the transaction causing all of the above buffered data to be sent to the printer printer.transactionPrint(POSPrinterConst.PTR_S_RECEIPT, POSPrinterConst.PTR_TP_NORMAL); // exit our printing loop } while (false); } catch(JposException e) { // display any errors that come up e.printStackTrace(); } finally { // close the printer object try { printer.close(); } catch (Exception e) {} } System.out.println("StarReceiptTest finished."); System.exit(0); } 

这是jpos.xml文件

                                                                         

我已经解决了我自己:)现在它工作正常。 感谢Joop试图帮助我。

这是我的解决方案。

  1. 设置执行APD_455dE.exe的打印机驱动程序

  2. 设置Epson_JavaPOS_ADK_11317

  3. 使用SetupPOS.exe生成Jpos.xml(通常位于C:\ Program Files \ EPSON \ JavaPOS \ SetupPOS \ SetupPOS.exe)

  4. 将Jpos.xml保存在src文件夹中

  5. 将以下jar文件添加到项目epsonJposService182.jar epsonJposServiceCommon.jar jpos18.jar xercesImpl.jar xml-apis.jar

  6. 使用以下代码System.setProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_PROP_NAME,“D:\ Test \ Jpos_Sample \ src \ jpos.xml”)为项目指定Jpos.xml文件;

  7. 准备好出发…!!!!

如果有人需要有关POS打印机问题的进一步帮助,请与我联系 我会尽力帮助你们。