Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
855 views
in Technique[技术] by (71.8m points)

printing - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  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;
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...