title: How can I use processing.app.Preferences in java?
body: <p>I wrote a java program to reading data from serial port.
  But I have an error.
  Can you help me?</p>
  
  <pre><code>import gnu.io.CommPortIdentifier;
  import gnu.io.SerialPort;
  import java.io.InputStream;
  import java.io.OutputStream;
  import processing.app.Preferences;
  
  public class Main {
      static InputStream input;
      static OutputStream output;
  
      public static void main(String[] args) throws Exception{
          Preferences.init(null);
          System.out.println("Using port: " + Preferences.get("serial.port"));
          CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(
                  Preferences.get("serial.port"));
  
          SerialPort port = (SerialPort)portId.open("serial talk", 4000);
          input = port.getInputStream();
          output = port.getOutputStream();
          port.setSerialPortParams(Preferences.getInteger("serial.debug_rate"),
                  SerialPort.DATABITS_8,
                  SerialPort.STOPBITS_1,
                  SerialPort.PARITY_NONE);
          while(true){
              while(input.available()&gt;0) {
                  System.out.print((char)(input.read()));
              }
          }
      }
  }
  </code></pre>
  
  <p>Error: init(String[]) has protected access in Preferences</p>