title: Linux printing in java
body: <p>I am using a thermal printer which kicks out the drawer before or after printing. But i want to stop that and i am sending a hex code to kickout the draw when needed. The sequence i am using is <code>openDrawerCommand = "\u001B\u0070\u0030\u0042\u0045";</code> This is working fine in windows but if i run this on linux i am getting some error not in the application but from the printer driver saying that "There was a problem processing document 'Java Printing'". What is this all about ? I thing there is something to do with the code so tat it runs well on all platforms.  The code i am using is shown below:</p>
  
  <pre><code>public OpenCashDrawer() {
      PrintService pservice = PrintServiceLookup.lookupDefaultPrintService();
      System.out.println("printservice"+pservice);
      try {
          DocPrintJob job = pservice.createPrintJob();
          String openDrawerCommand = ((char)0x1B70111)+"";
          //
          openDrawerCommand = "\u001B\u0070\u0030\u0042\u0045";
          byte by[] = openDrawerCommand.getBytes();
          //char[] printdata = "hello world\n".toCharArray();
          // System.out.println(by[1]);
          DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
          //PrintService pservice = PrintServiceLookup.lookupDefaultPrintService();
          //DocPrintJob pjob = pservice.createPrintJob();
          //DocFlavor flavor = DocFlavor.CHAR_ARRAY.TEXT_PLAIN;
          Doc doc = new SimpleDoc(by, flavor, null);
          job.print(doc, null);
      } catch (Exception e) {
          System.out.println("Whoa bro. The printer is balls. Check it:");
          e.printStackTrace();
      }
  }
  </code></pre>