1

I'm developing an application which implements JavaPOS. I have configured the setting correctly but I still not able to print the receipt. (I can make a print from CITIZEN JavaPOS TEST PRO Ver.1.3.4 but not from my program)

Here is some part of my code:

import jpos.*;
import jpos.util.JposPropertiesConst;

...

System.setProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_PROP_NAME,"C:\\path_to_config\\jpos.xml");

...

POSPrinter printer = new POSPrinter();
try {
  printer.open("CITIZEN S310II USB Windows");
  printer.claim(100);
  printer.setDeviceEnabled(true);
  printer.setMapMode(POSPrinterConst.PTR_MM_METRIC);

  printer.transactionPrint(POSPrinterConst.PTR_S_RECEIPT, POSPrinterConst.PTR_TP_TRANSACTION);

  String LF     = ((char) 0x0a) + "";
  printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, "TEST" + LF + LF + LF);
  printer.cutPaper(100);
} catch (Exception e) {
  e.printStackTrace();
} finally {
  try {
    printer.setDeviceEnabled(false);
    printer.release();
    printer.close();
  } catch (Exception e) {
    e.printStackTrace();
  }
}

....

The error occurred when I tried to call printer.claim(1000); stating

jpos.JposException: CSJjposCom access error.
    at com.citizen.jpos.b.e.d(Unknown Source)
    at com.citizen.jpos.b.e.claim(Unknown Source)
    at jpos.BaseJposControl.claim(Unknown Source)
    at simplepos.billUI.printBill(billUI.java)
    ....

My library are:

./CBMjpos.jar
./lib/comm.jar
./lib/jna.jar
./lib/xerces-2.6.0.jar
./lib/xerces2.jar
./lib/

Please help, I can't find any resource to fix this problem

Davide Pastore
  • 8,678
  • 10
  • 39
  • 53
  • Are you sure the test program is shutdown? – JJF Nov 29 '15 at 18:45
  • @JJF Yes. I even restarted my computer, still, showing the same error – Suphakrit Phantharat Nov 30 '15 at 12:35
  • i have notice that `CSJjposCom` is one of the provided `dll` (`CSJjposCom.dll` and `CSJjposBcw.dll`) so I have tried compiling with the flag `-Djava.library.path=`, still no use. – Suphakrit Phantharat Nov 30 '15 at 17:17
  • Do you have the source to the demo program? – JJF Nov 30 '15 at 17:37
  • @JJF Unfortunately, I don't have it. – Suphakrit Phantharat Dec 01 '15 at 01:42
  • Can you read any properties of the printer? You might be right about the native library. Claim is the first call that would cause the driver to try to make a call to the service object. Also, you don't wnt the -Djava.library.path define on the compile phase. You need to specifiy that define when you *RUN* your program. – JJF Dec 01 '15 at 11:38
  • My mistake. But the question is, how can you read properties of the printer if it's not claimed? – Suphakrit Phantharat Dec 01 '15 at 17:30
  • You should be able to read something like device name without having to claim the device. Try anything. – JJF Dec 01 '15 at 18:14
  • @Suphakrit Phantharat Hi Suphakrit, I also came across the same problem with `jpos.JposException: CSJjposCom access` error while running Linux 64-Bit. Have you found a solution yet and would you mind sharing it with the community? Thank you very much for your efforts – Chiggiddi Sep 07 '16 at 11:28
  • @Chiggiddi sorry, i have not found any solution for me. Also, my printer doesn't support codepage that i wanted, thus having to print 3 lines for one actual line. I moved on to printing pdf instread :( – Suphakrit Phantharat May 11 '18 at 04:33

1 Answers1

0

It is occurred because of special permission needed.

Add this in manifest file and try. Help for me.

<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />