title: Print Zebra ZM400 using Java
body: <p>my printer is Zebra ZM400 label printer and it's connected to one of the pc (connected with USB) in the network.</p>
  
  <p>I want to send the command to the label printer from my pc via network and print label.</p>
  
  <p>How to connect that printer from network and print label from java application?</p>
  
  <p>I know I've to use ZPL langauage but I don't know how to make connection and send command to label printer.</p>
  
  <p>Is it possible? I surfed in the google but i can't find any sample code yet.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I used norbi771's method.. but when it sent the command, just blank come out..</p>
  
  <p>my label's dimension is 3.25" x 3.75"..</p>
  
  <p>This is my sample code for label .. but nothing comes out..</p>
  
  <pre><code>public class TestLabelPrinter {
  
      /**
       * @param args
       */
      public static void printLabel(String label, String company, String docDate)  {
          try {
              FileOutputStream os = new FileOutputStream("\\\\192.168.42.57\\zd");
              PrintStream ps = new PrintStream(os); 
              String commands = "^XA" +
                                "^LH30,30" +
                                "^F020,10^AD^FDZEBRA^FS" + 
                                "F020,60^B3^FDAAA001^FS" + 
                                "^XZ";     
  
              ps.println(commands);
              ps.print("\f");
              ps.close();
          } catch (Exception e) {
              // TODO: handle exception
              e.printStackTrace();
          }
  
      }
  
      public static void main(String[] args) {
          // TODO Auto-generated method stub
          printLabel("label 12345", "Company name", "2013-05-10 12:45");
          System.out.println("Successful..");
      }
  </code></pre>