JavaPOS Hello World in Java
Asked Answered
V

1

9

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.

Visit answered 4/11, 2009 at 16:39 Comment(0)
V
16

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.

Visit answered 5/11, 2009 at 18:37 Comment(4)
I hope this will save someone else a few hours of research.Visit
thanks... didn't realise the jpos.xml file had to be generated from the star config utility until i read your answer. For those of you who can't find it... you need to open your Star Config Utility in Star Line Mode, click JavaPOS on the left side, press "Create JavaPOS XML Registry File", then click Add New for your printer and cash drawer, then click Apply - the jpos.xml file will be automatically updated. Finally replace [Device].open("default") to the Logical Name written in the jpos.xml file.Derte
Hey Philippe could you share the JavaPos Hello world program i am a newbie trying to print a reciept in my app using a pos printer. Your program would be very helpful buddyAndel
This was almost 5 years ago, I don't have the code anymore. But from what I can recall, this answer contains most of what is needed. POSPrinter printer = new POSPrinter(); printer.open("printerName"); printer.printnormal("Hello World"); printer.transactionPrint(); If you configured your jpos.xml correctly, it should work.Visit

© 2022 - 2024 — McMap. All rights reserved.