title: java RXTX send string
body: <p>i'm trying to use the RXTX java library to send strings by click listeners in my gui, but i can't edit the code of the RXTX to send strings , where it only responds to input from the console, so how can i edit the code to not only send data that is input from the console?</p>
  
  <p>i'm using the same code here:</p>
  
  <p><a href="http://rxtx.qbang.org/wiki/index.php/Two_way_communcation_with_the_serial_port" rel="nofollow noreferrer">http://rxtx.qbang.org/wiki/index.php/Two_way_communcation_with_the_serial_port</a></p>
  
  <p>I have tried writing this extra function and called it from other classes:</p>
  
  <pre><code>public void writetoport() {
      String serialMessage = "test";
      try {
          // i have made 'out' as a global variable// 
          this.out.write(serialMessage.getBytes());
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>But I get this error in the console:</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
  at TwoWaySerialComm.writetoport(TwoWaySerialComm.java:121)
  </code></pre>