title: Print a simple text to a paper in Java
body: <p>I need to print to the default printer in windows with Java.  I found some sample code on the  internet.  The code compiles without error.  But when ran, I get the following error:</p>
  
  <pre><code>**  Exception in thread "Thread-4" java.lang.NullPointerException
         at sun.awt.windows.WprinterJob.NullPointerException 
         at sun.awt.windows.WprinterDialogPeer._show(Native Method)
         at sun.awt.windows.WprinterDialogPeer.access$000(Unknown Source)
         at sun.awt.windows.WprinterDialogPeer$1.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)**
  </code></pre>
  
  <p>The program shows the dialog box.  However, when I click on the print button it gives me the exception.  I think this is a case with java Print component.  What can i do to correct this?</p>