6

I am developing a Point Of Sale application, and one of the functionality is to print receipt in a thermal/receipt printer. Currently I have a Datecs DPP-255 printer.

I have no idea where to begin my quest.

I tried search through internet, found out that JavaPOS/UnifiedPOS exists but I couldn't find enough documentation to get me started. Please shed some light.

informatik01
  • 16,038
  • 10
  • 74
  • 104
Yunus Einsteinium
  • 1,102
  • 4
  • 21
  • 55

2 Answers2

4

Here is an open source project for testing, that may also be used as a reference on how to program using JavaPOS (source code available):

Also here are some projects hosted on GitHub (see the source code to get the idea and to play with):


Related links:


NOTE:
in order to utilize JavaPOS (which is now a part of the UnifiedPOS specification, see Appendix B), the producer of your Datecs DPP-255 device must provide the related drivers. Are they provided? JavaPOS - is a specification, so accordingly there must be some implementation of it.

Community
  • 1
  • 1
informatik01
  • 16,038
  • 10
  • 74
  • 104
  • i create a project for above POStest, the following error i got jpos/res/jpos.properties file not found jpos/res/jpos.properties file not found Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xerces/parsers/DOMParser – Yunus Einsteinium Aug 18 '15 at 13:35
  • @YunusEinsteinium Seems like Apache Xerces library is not available on the classpath. I have updated a link to POSTest project (the first link), the initial page seems to be outdated, so there is a version 2 of this project that is more up to date (plus bug fixes). Download from there, that ZIP file definitely contains _xerces,jar_ file. – informatik01 Aug 18 '15 at 14:09
  • And the *jpos.properties* is not on the classpath too. Btw the new POSTest 2 project is Maven based, so it has the required dependency (*Apache Xerces*) defined in the POM file. The binary (i.e. the compiled POSTest) has the *xerces.jar*. – informatik01 Aug 18 '15 at 15:30
  • Thanks for the update. I used the sourceforge project(updated--2), and when build and downloading dependencies an error displayed in console: Compilation failure javapospostest2-code-9501d6413ba6c19d87b19be2123a9010cb3b0d4f\src\main\java\postest2\POSTest2Controller.java:[424,6] error: try-with-resources is not supported in -source 1.5 -> [Help 1] For more information about the errors and possible solutions, please read the following articles: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException – Yunus Einsteinium Aug 19 '15 at 06:42
  • In the file POSTest2Controller.java, an error is shown in this code // Clear file and write new path! try (PrintWriter writer = new PrintWriter(f)) { writer.print(""); } catch (FileNotFoundException e1) { e1.printStackTrace(); } : a red underline in the try saying: try-with-resources is not supported in -source 1.5 (use -source 7 or higher to support try-with-resources) – Yunus Einsteinium Aug 19 '15 at 06:45
  • @YunusEinsteinium By default Maven currently uses Java 1.5. Add this to your POM: ` org.apache.maven.plugins maven-compiler-plugin 3.3 1.7 1.7 `. See this for more: [Setting the -source and -target of the Java Compiler](https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html) – informatik01 Aug 19 '15 at 09:18
  • **Try with resources** is available *since Java 7* (1.7), that's why you were getting this error. Also POSTest 2 project has a ["**Discussion**"](http://sourceforge.net/p/javapospostest2/discussion/) area (forum), so you could also try to ask for help right from the authors of this project, in case something specific needs clarification. P.S. Don't give up )) – informatik01 Aug 19 '15 at 09:26
1

So it looks like this printer supports something called ESC/POS, which is like a command set that allows you to print and format data. There are a few guides available online, this is one I've used before: http://www.starmicronics.com/support/mannualfolder/escpos_cm_en.pdf

Note that printers sometimes subtly differ in which command sets from ESC/POS they support, so you might have a bit of trial and error on your hands.

In terms of sending that data to the printer, it depends on what type of connection it is. For serial, you should just be able to open and write to that port, using the ESC/POS command set.

Not all of the data you will send will be ASCII or UTF encoded, a lot of them are binary values you need to send. So for example, to tell the printer to write a new line, the Hex value for that is 0A. So in Java you would need to specify that as String s = "\u000A"; etc.

For java you will need to download the Java Comm API from http://java.sun.com/products/javacomm/

There is a tutorial on this here: http://www.java-samples.com/showtutorial.php?tutorialid=214

Hopefully this helps.

  • Note the installation of Java Comm is really painful. It includes copying dll's directly into the jvm installation. An alternative is just using plink(from putty) which is just started as a process from java and read/write with stdio. – Esben Skov Pedersen Aug 18 '15 at 12:07
  • Also I had some stability issues with java comm last time I used it. If using plink, the plink process can just be killed and restarted in event of an error and will then release all resources back to the OS. – Esben Skov Pedersen Aug 18 '15 at 12:08
  • `"\u000A"` is also known as `"\n"`, i.e. newline. And "\u000A" won't work as the Java compiler will interpret that as a literal linebreak within quotes. See http://stackoverflow.com/questions/3866187/why-cant-i-use-u000d-and-u000a-as-cr-and-lf-in-java – Christoffer Hammarström Aug 18 '15 at 12:11
  • @ChristofferHammarström ah okay, sorry, I've only done this in c#, so I just checked online :) thanks for the feedback – Keiran van Vuuren Aug 18 '15 at 12:47
  • 1
    Just specifying the string as `"\n"` instead should work. – Christoffer Hammarström Aug 18 '15 at 12:53