method init in class Preferences cannot be applied to given types;
required: String
found: no arguments
reason: actual and formal argument lists differ in length
并Preferences.init();
在 NetBeans 中标记为红色
不知道是什么问题?
运行时出现以下错误:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: processing.app.Preferences.init
at arduinojava.ArduinoJava.main(ArduinoJava.java:34)
Java Result: 1
这是代码:
/*
* This class will get the input from arduino board and output
* the data to the scanner
* Code adopted from Silveira Neto
*/
package arduinojava;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import java.io.InputStream;
import java.io.OutputStream;
import processing.app.Preferences;
/**
*
* @author kinley tshering
*/
public class ArduinoJava {
static InputStream input;
static OutputStream output;
static CommPortIdentifier portId;
static SerialPort port;
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//code application logic here
Preferences.init();
System.out.println("Using port: " + Preferences.get("serial.port"));
try {
portId = CommPortIdentifier.getPortIdentifier(
Preferences.get("serial.port"));
//port = (SerialPort)portId.open("serial talk", 4000);
port = (SerialPort)portId.open("", 4500);
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() > 0) {
System.out.print((char)(input.read()));
}
}
}
catch(gnu.io.NoSuchPortException nsp) {
System.err.println("ERROR: " + nsp.getMessage());
}
catch(gnu.io.UnsupportedCommOperationException usp) {
System.err.println("ERROR: " + usp.getMessage());
}
catch(gnu.io.PortInUseException pie) {
System.err.println("ERROR: Port " + port + " is already in use\nCLose the port and restart.");
}
catch(java.io.IOException ioe) {
System.err.println("IO ERROR: " + ioe.getMessage() );
}
catch(Exception exe) {
System.err.println("ERROR: Unexpected error occured \n" + exe.getMessage() );
}
}
}