1

I'm trying to use javapos for an android application and I'm having quite an hard time making it works.

Here's what I tried untill now.

I have the jars of javapos an the jpos.xml file, which was given to me by the vendor of the printer. I loaded the jars inside the lib folder and jpos.xml inside the root folder of the application (I'm not sure if it is where it has to be). The I wrote the java to connect to it :

System.setProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_PROP_NAME, "jpos.xml");

POSPrinter printer =  new POSPrinter();

try {
            printer.open("printf");
            printer.claim(100);
            printer.setDeviceEnabled(true);

            printer.printNormal(1, "PRINT?");

 } catch (jpos.JposException e) {
            e.printStackTrace();
 }

Where "printf" is the logicName inside my xml.
But when I try to print I always get this error :

pos.JposException: Service does not exist in loaded JCL registry 

at jpos.loader.simple.SimpleServiceManager.createConnection(Unknown Source)

at jpos.loader.JposServiceLoader.findService(Unknown Source)

at jpos.BaseJposControl.open(Unknown Source)

So, my questions are:
is what I'm tring to do right? It is even possible? because I have seen a couple of question about this, but never on an android application.
If it is possible, how can I tell my application where to find JCL registry?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Tiz
  • 413
  • 1
  • 5
  • 21
  • If your printer and JavaPOS can run on Windows, [the answer to this article](https://stackoverflow.com/questions/30839049/how-can-i-use-javapos-to-print-reciepts-with-an-epson-printer) is to make the EPSON printer and its JavaPOS available on Windows. Please try replacing the contents with your printer and running on Windows. – kunif Jan 11 '18 at 14:01

2 Answers2

0

I had the same issue with a scanner interface , i solved the problem including my jpos.xml (verify that profile name you are using inside your code meets exactly the profile name inside your xml file), like this: enter image description here

hope still can help !

Siberia
  • 117
  • 1
  • 5
  • 13
0

You got the error because of invalid device name you specified to open.

try this:

String deviceName = "HPPrinter" // or what your device name is
printer.open(deviceName);

instead of:

printer.open("printf");
Kumar Saurabh
  • 2,297
  • 5
  • 29
  • 43
ubasarir
  • 1
  • 1
  • 3