Java中的JavaPOS Hello World [英] JavaPOS Hello World in Java

查看:135
本文介绍了Java中的JavaPOS Hello World的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从Windows XP上的java程序在我的USB POS(销售点)打印机上打印一个样本行。

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

我试图设置一个JavaPOS实现,但是在缺少jpos.xml或缺少javax.usb.properties文件的异常之后我得到了异常。

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.

我目前的打印机型号是带有USB接口的Star TSP 100。我的打印机似乎连接正确,因为我可以从Windows上打印文件。

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.

推荐答案

好吧,我终于找到了它自己。看起来你需要JavaPOS程序的一部分(该部分只有接口和抽象类),你需要来自设备制造商的库。安装打印机后会生成jpos.xml。软件(也由制造商提供)根据打印机名称和其他设置在jpos.xml文件中生成条目。您必须在程序中包含此文件。

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");

然后使用printnormal()方法进行打印。如果您异步打印,还需要transactionPrint()来清空缓冲区。

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

这篇关于Java中的JavaPOS Hello World的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆