Java中pos,Java中的JavaPOS Hello World

I would like to print a sample line on my USB POS (Point-Of-Sale) printer from a java program on Windows XP.

I tried to setup a JavaPOS implementation but I get exception after exception for a missing jpos.xml or missing javax.usb.properties file.

Can anyone tell me how to generate those files? They somewhat need to link to an implementation or something like that and I'm not sure what the (rare, unclear and incomplete) documentation means. Any other help would be appreciated.

My current printer model is Star TSP 100 with a USB connector. My printer seems to be connected correctly since I can print a file on it from windows.

解决方案

Well, I finally found it myself. It seems like you need a part of the program from JavaPOS (that part only has interfaces and abstract classes) and you need the library from the manufacturer of the device. The jpos.xml is generated after the printer is installed. A software (also provided by the manufacturer) generates entries in the jpos.xml file based on the name of the printer and other settings. You must include this file in your program.

Finally, the following code makes the connection to the printer :

POSPrinter printer = new POSPrinter();

// open the printer object according to the entry names defined in jpos.xml

printer.open("printerName");

The method printnormal() is then used to print. If you printing asynchonously, you also need transactionPrint() to empty the buffer.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值