简体   繁体   English

Java中的JavaPOS Hello World

[英]JavaPOS Hello World in Java

I would like to print a sample line on my USB POS (Point-Of-Sale) printer from a java program on Windows XP. 我想从Windows XP上的java程序在我的USB POS(销售点)打印机上打印一个样本行。

I tried to setup a JavaPOS implementation but I get exception after exception for a missing jpos.xml or missing javax.usb.properties file. 我试图设置一个JavaPOS实现,但是在缺少jpos.xml或缺少javax.usb.properties文件的异常之后我得到了异常。

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. 我目前的打印机型号是带有USB接口的Star TSP 100。 My printer seems to be connected correctly since I can print a file on it from windows. 我的打印机似乎连接正确,因为我可以从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. 看起来您需要JavaPOS程序的一部分(该部分只有接口和抽象类),您需要来自设备制造商的库。 The jpos.xml is generated after the printer is installed. 安装打印机后会生成jpos.xml。 A software (also provided by the manufacturer) generates entries in the jpos.xml file based on the name of the printer and other settings. 软件(也由制造商提供)根据打印机名称和其他设置在jpos.xml文件中生成条目。 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. 然后使用printnormal()方法进行打印。 If you printing asynchonously, you also need transactionPrint() to empty the buffer. 如果您异步打印,还需要transactionPrint()来清空缓冲区。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM