title: Java POS printer error
body: <p>I'm novice to Java, and I'm developing POS application using java. </p>
  
  <p>I bought an Epson POS printer for this project. Printer model is <code>EPSON TM-U220.</code></p>
  
  <p>I've installed <code>JavaPos</code> and, my code snippet as follows. but when running I get this error.</p>
  
  <p>Appreciate if anyone could help me with this problem.</p>
  
  <hr>
  
  <pre><code>run:
  jpos.JposException: Service does not exist in loaded JCL registry
  StarReceiptTest finished.
      at jpos.loader.simple.SimpleServiceManager.createConnection(SimpleServiceManager.java:179)
      at jpos.loader.JposServiceLoader.findService(JposServiceLoader.java:154)
      at jpos.BaseJposControl.open(BaseJposControl.java:481)
      at StarReceiptTest.main(StarReceiptTest.java:54)
  BUILD SUCCESSFUL (total time: 1 second)
  </code></pre>
  
  <hr>
  
  <pre><code>import jpos.JposConst;
  import jpos.JposException;
  import jpos.POSPrinter;
  import jpos.POSPrinterConst;
  
  import jpos.util.JposPropertiesConst;
  
  public class StarReceiptTest
  {
      public static void main(String[] args){   
          /*
          If you want to place the jpos.xml file elsewhere on your local file system then uncomment the
          following line and specify the full path to jpos.xml.
  
          If you want to place the jpos.xml file on a webserver for access over the internet then uncomment
          the second System.setProperty line below and specify the full URL to jpos.xml.
          */
          //C:\Users\Udayanga\Documents\NetBeansProjects\Jpos_Sample\src
          //System.setProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_PROP_NAME, "jpos.xml");
          System.setProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_PROP_NAME, "C:\\Users\\Udayanga\\Documents\\NetBeansProjects\\Jpos_Sample\\src\\jpos.xml");
          //System.setProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_URL_PROP_NAME, "http://some-where-remote.com/jpos.xml");
  
          // constants defined for convience sake (could be inlined)
          String ESC    = ((char) 0x1b) + "";
          String LF     = ((char) 0x0a) + "";
          String SPACES = "                                                                      ";
  
          // instantiate a new jpos.POSPrinter object
          POSPrinter printer = new POSPrinter();
          //ESDPRT001 = Port
          try
          {
              // open the printer object according to the entry names defined in jpos.xml
              //printer.open("startsp");
  
              //ESDPRT001
              printer.open("TM-U220");
  
              // claim exclsive usage of the printer object
              printer.claim(1);
  
              // enable the device for input and output
              printer.setDeviceEnabled(true);
  
              // set map mode to metric - all dimensions specified in 1/100mm units
              printer.setMapMode(POSPrinterConst.PTR_MM_METRIC);  // unit = 1/100 mm - i.e. 1 cm = 10 mm = 10 * 100 units
  
              do
              {
                  // poll for printer status
                  //   a javax.swing based application would be best to both poll for status
                  //   AND register for asynchronous StatusUpdateEvent notification
                  //   see the JavaPOS specification for details on this
  
                  // check if the cover is open
                  if (printer.getCoverOpen() == true)
                  {
                      System.out.println("printer.getCoverOpen() == true");
  
                      // cover open so do not attempt printing
                      break;
                  }
  
                  // check if the printer is out of paper
                  if (printer.getRecEmpty() == true)
                  {
                      System.out.println("printer.getRecEmpty() == true");
  
                      // the printer is out of paper so do not attempt printing
                      break;
                  }
  
                  // being a transaction
                  //   transaction mode causes all output to be buffered
                  //   once transaction mode is terminated, the buffered data is
                  //   outputted to the printer in one shot - increased reliability
                  printer.transactionPrint(POSPrinterConst.PTR_S_RECEIPT, POSPrinterConst.PTR_TP_TRANSACTION);
  
                  if (printer.getCapRecBitmap() == true){
                      // print an image file
                      try
                      {
                          printer.printBitmap(POSPrinterConst.PTR_S_RECEIPT, "star.gif", POSPrinterConst.PTR_BM_ASIS, POSPrinterConst.PTR_BM_CENTER);
                      }
                      catch (JposException e)
                      {
                          if (e.getErrorCode () != JposConst.JPOS_E_NOEXIST)
                          {
                              // error other than file not exist - propogate it
                              throw e;
                          }
  
                          // image file not found - ignore this error &amp; proceed
                      }
                  }
  
                  // call printNormal repeatedly to generate out receipt
                  //   the following JavaPOS-POSPrinter control code sequences are used here
                  //   ESC + "|cA"          -&gt; center alignment
                  //   ESC + "|4C"          -&gt; double high double wide character printing
                  //   ESC + "|bC"          -&gt; bold character printing
                  //   ESC + "|uC"          -&gt; underline character printing
                  //   ESC + "|rA"          -&gt; right alignment
  
                  printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, ESC + "|cA" + ESC + "|4C" + ESC + "|bC" + "Star Grocer"     + LF);
                  printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, ESC + "|cA" + ESC + "|bC" +               "Shizuoka, Japan" + LF);
                  printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, ESC + "|cA" + ESC + "|bC" +               "054-555-5555"    + LF);
  
                  printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, ESC + "|uC" + "Qnty Unit Tx Description" + SPACES.substring(0, printer.getRecLineChars() - "Qnty Unit Tx Description".length()) + LF);
  
                  printer.printNormal(POSPrinterConst.PTR_S_RECEIPT,               "   1  830    Soba Noodles"        + LF);
                  printer.printNormal(POSPrinterConst.PTR_S_RECEIPT,               "   1  180    Daikon Radish"       + LF);
                  printer.printNormal(POSPrinterConst.PTR_S_RECEIPT,               "   1  350    Shouyu Soy Sauce"    + LF);
                  printer.printNormal(POSPrinterConst.PTR_S_RECEIPT,               "   1   80    Negi Green Onions"   + LF);
                  printer.printNormal(POSPrinterConst.PTR_S_RECEIPT,               "   1  100    Wasabi Horse Radish" + LF);
                  printer.printNormal(POSPrinterConst.PTR_S_RECEIPT,               "   2  200 Tx Hashi Chop Sticks"   + LF);
                  printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, LF);
  
                  printer.printNormal(POSPrinterConst.PTR_S_RECEIPT,               ESC + "|rA" +               "Subtotal:  2160" + LF);
                  printer.printNormal(POSPrinterConst.PTR_S_RECEIPT,               ESC + "|rA" +               "Tax:         24" + LF);
                  printer.printNormal(POSPrinterConst.PTR_S_RECEIPT,               ESC + "|rA" + ESC + "|bC" + "Total:     2184" + LF);
                  printer.printNormal(POSPrinterConst.PTR_S_RECEIPT,               ESC + "|rA" +               "Tender:    2200" + LF);
                  printer.printNormal(POSPrinterConst.PTR_S_RECEIPT,               ESC + "|rA" + ESC + "|bC" + "Change:      16" + LF);
                  printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, LF);
  
                  if (printer.getCapRecBarCode() == true)
                  {
                      // print a Code 3 of 9 barcode with the data "123456789012" encoded
                      //   the 10 * 100, 60 * 100 parameters below specify the barcode's height and width
                      //   in the metric map mode (1cm tall, 6cm wide)
                      printer.printBarCode(POSPrinterConst.PTR_S_RECEIPT, "123456789012", POSPrinterConst.PTR_BCS_Code39, 10 * 100, 60 * 100, POSPrinterConst.PTR_BC_CENTER, POSPrinterConst.PTR_BC_TEXT_BELOW);
                  }
  
                  printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, ESC + "|cA" + ESC + "|4C" + ESC + "|bC" + "Thank you" + LF);
  
                  // the ESC + "|100fP" control code causes the printer to execute a paper cut
                  //   after feeding to the cutter position
                  printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, ESC + "|100fP");
  
                  // terminate the transaction causing all of the above buffered data to be sent to the printer
                  printer.transactionPrint(POSPrinterConst.PTR_S_RECEIPT, POSPrinterConst.PTR_TP_NORMAL);
  
                  // exit our printing loop
              } while (false);
          }
          catch(JposException e)
          {
              // display any errors that come up
              e.printStackTrace();
          }
          finally
          {
              // close the printer object
              try
              {
                  printer.close();
              }
              catch (Exception e) {}
          }
  
          System.out.println("StarReceiptTest finished.");
          System.exit(0);
      }
  </code></pre>
  
  <p>Here is the jpos.xml file</p>
  
  <p>
          
          
          
          </p>
  
  <pre><code>    &lt;!--Other non JavaPOS required property (mostly vendor properties and bus specific properties i.e. RS232 )--&gt;
      &lt;prop name="Halftone" type="String" value="0"/&gt;
      &lt;prop name="PhysicalPrinterName" type="String" value="TM-U220"/&gt;
      &lt;prop name="NVRAMControlLevel" type="String" value="1"/&gt;
      &lt;prop name="Stamp" type="String" value="0"/&gt;
      &lt;prop name="OutputCompleteType" type="String" value="2"/&gt;
      &lt;prop name="StatusThreadInterval" type="String" value="100"/&gt;
      &lt;prop name="OutputTimeout" type="String" value="500"/&gt;
      &lt;prop name="PortType" type="String" value="2"/&gt;
      &lt;prop name="OutputBufferSize" type="String" value="65536"/&gt;
      &lt;prop name="UsedNVRAM" type="String" value="0"/&gt;
      &lt;prop name="FirmRecordLog" type="String" value="1"/&gt;
      &lt;prop name="ReceiveTimeout" type="String" value="1000"/&gt;
      &lt;prop name="SlpReverseEject" type="String" value="0"/&gt;
      &lt;prop name="PortName" type="String" value="TM-U220"/&gt;
      &lt;prop name="OfflineRetryIntervalTime" type="String" value="25"/&gt;
      &lt;prop name="DefaultSlpClampTime" type="String" value="0"/&gt;
      &lt;prop name="epson.trace.file" type="String" value="trace.log"/&gt;
      &lt;prop name="AsyncProcessingSize" type="String" value="1"/&gt;
      &lt;prop name="KanjiTwoWaysPrint" type="String" value="0"/&gt;
      &lt;prop name="PulseStep" type="String" value="2"/&gt;
      &lt;prop name="PortInterfaceName" type="String" value="USB"/&gt;
      &lt;prop name="OutPipe" type="String" value="0"/&gt;
      &lt;prop name="U375Compatible" type="String" value="0"/&gt;
      &lt;prop name="PortNameType" type="String" value="0"/&gt;
      &lt;prop name="preCutterFunction" type="String" value="0"/&gt;
      &lt;prop name="epson.tracing" type="String" value="false"/&gt;
      &lt;prop name="epson.trace.max.size" type="String" value="1000"/&gt;
      &lt;prop name="RecPaperSize" type="String" value="76"/&gt;
      &lt;prop name="DeviceDesc" type="String" value="EPSON TM-U220D POSPrinter"/&gt;
      &lt;prop name="PageModeExt" type="String" value="0"/&gt;
      &lt;prop name="SupportStatistics" type="String" value="1"/&gt;
      &lt;prop name="FirmProgressRange" type="String" value="10"/&gt;
      &lt;prop name="OutputErrorOption" type="String" value="0"/&gt;
      &lt;prop name="SupportFirmware" type="String" value="0"/&gt;
      &lt;prop name="InputTimeout" type="String" value="100"/&gt;
      &lt;prop name="AutoPowerOff" type="String" value="0"/&gt;
      &lt;prop name="SlpMoreColumns" type="String" value="0"/&gt;
      &lt;prop name="RecPaperType" type="String" value="0"/&gt;
      &lt;prop name="MemorySwitch" type="String" value="0"/&gt;
      &lt;prop name="ReadThreadInterval" type="String" value="-1"/&gt;
      &lt;prop name="QueuingOfflineTimeout" type="String" value="1000"/&gt;
      &lt;prop name="InitializeThreadTime" type="String" value="1000"/&gt;
      &lt;prop name="TwoColor" type="String" value="1"/&gt;
      &lt;prop name="TwoByteCharacter" type="String" value="0"/&gt;
      &lt;prop name="FirmLogFileSize" type="String" value="1000"/&gt;
      &lt;prop name="Peeler" type="String" value="0"/&gt;
      &lt;prop name="InPipe" type="String" value="1"/&gt;
      &lt;prop name="ConfigurationFile" type="String" value="epson/xml/Setting/TM-U220DSetting.xml"/&gt;
      &lt;prop name="Custom1Color" type="String" value="0xFF0000"/&gt;
      &lt;prop name="preEndorseFunction" type="String" value="0"/&gt;
      &lt;prop name="Upos.Spec_c" type="String" value="false"/&gt;
      &lt;prop name="FirmNotifyAllProgressEvents" type="String" value="0"/&gt;
      &lt;prop name="InitializeResponseTimeout" type="String" value="1000"/&gt;
      &lt;prop name="ReceiveRetryTime" type="String" value="25"/&gt;
      &lt;prop name="PrinterTransmitTimeout" type="String" value="30000"/&gt;
      &lt;prop name="RecMoreColumns" type="String" value="0"/&gt;
      &lt;prop name="UsedInterCharacterSet" type="String" value="0"/&gt;
      &lt;prop name="WriteThreadInterval" type="String" value="-1"/&gt;
      &lt;prop name="preORCBFunction" type="String" value="0"/&gt;
      &lt;prop name="RecNearEndSensor" type="String" value="1"/&gt;
      &lt;prop name="LogObject" type="String" value=""/&gt;
      &lt;prop name="Cutter" type="String" value="0"/&gt;
      &lt;prop name="PhysicalDevice" type="String" value="TM-U220D"/&gt;
      &lt;prop name="UsedPeeler" type="String" value="0"/&gt;
      &lt;prop name="FirmLogFileName" type="String" value="Firmware.log"/&gt;
      &lt;prop name="InputBufferSize" type="String" value="4096"/&gt;
      &lt;prop name="TransmitTimeout" type="String" value="5000"/&gt;
      &lt;prop name="OfflineCount" type="String" value="2"/&gt;
      &lt;prop name="TransmitRetryTime" type="String" value="100"/&gt;
      &lt;prop name="DirectIOEventTimeout" type="String" value="5000"/&gt;
  </code></pre>
  
  <p></p>