How can I use JavaPOS to print reciepts with an Epson printer?

How can I develop Java Software to print reciepts with an Epson reciept printer?


Solution 1:

  1. Get the Epson JavaPOS ADK from the Epson website, you'll need to register to download it.
  2. Be sure you have a 32-bit JVM installed
  3. Install the Epson JavaPOS ADK
    • select 32-bit JVM
    • select option that lib files are copied to the jvm's ext folder.
    • create a port for your printer
  4. In the installation folder: Epson/JavaPos/checkHealth can be used to check if your printer is connected correctly.
  5. Run Epson/JavaPos/setupPOS/setupPOS.exe, you will create a jpos.xml file which lets your java programm know which deviced are connected where and should be configured how.
    • Press new
    • Add your devices
    • Save the JPos.xml file
  6. You can test your installation with: http://sourceforge.net/projects/javapospostest2/ select there your newly created jpos.xml
  7. You can specify a specific path to your jpos.xml in Java with: System.setProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_PROP_NAME, System.getenv("jposxml_path")); I used a system-enviroment variable but you can use of course any other way to specify the path.

Now you are ready to go!

Example:

POSPrinterControl113 printer = (jpos.POSPrinterControl113) new POSPrinter();
CashDrawerControl113 drawer = (CashDrawerControl113) new CashDrawer();
try {
        printer.open("POSPrinter");
        printer.claim(100);

        printer.setDeviceEnabled(true);
    } catch (Exception e) {
        System.err.println("Printer deactivated " + e.getMessage());
        printerdisabled = true;
        drawerdisabled  = true;
        return;
    }
    try {
        drawer.open("CashDrawer");
        drawer.claim(100);
        drawer.setDeviceEnabled(true);
    } catch (Exception e) {
        System.out.println("Cashdrawer deactivated: " + e.getMessage());
        drawerdisabled = true;
        return;
    }