package NClang.tinycompile;
import org.sintef.jarduino.DigitalPin;
import org.sintef.jarduino.DigitalState;
import org.sintef.jarduino.JArduino;
import org.sintef.jarduino.PinMode;
import org.sintef.jarduino.comm.Serial4JArduino;
public class Blink extends JArduino {
public Blink(String port) {
super(port);
}
protected void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(DigitalPin.PIN_12, PinMode.OUTPUT);
}
@Override
protected void loop() {
// set the LED on
digitalWrite(DigitalPin.PIN_12, DigitalState.HIGH);
delay(1000); // wait for a second
// set the LED off
digitalWrite(DigitalPin.PIN_12, DigitalState.LOW);
delay(1000); // wait for a second
}
public static void main(String[] args) {
String serialPort;
if (args.length == 1) {
serialPort = args[0];
} else {
serialPort = Serial4JArduino.selectSerialPort();
}
JArduino arduino = new Blink(serialPort);
arduino.runArduinoProcess();
}
}
这是我在 Arduino Uno 板上闪烁 LED 的代码,但它会抛出
Load RxTx
java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver
Exception in thread "main" java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:123)
at org.sintef.jarduino.comm.Serial4JArduino.getAvailableSerialPorts(Serial4JArduino.java:244)
at org.sintef.jarduino.comm.Serial4JArduino.selectSerialPort(Serial4JArduino.java:289)
at NClang.tinycompile.Blink.main(Blink.java:36)
我已将 rxtxSerial 库导入我的路径,当我尝试再次导入它时,它说:
rxtxSerial already in path, no changes have been made
我在这个网站上看过一些关于这个问题的帖子,但他们都说“将 rxtxSerailcomm.jar 和 .dll 导入正确的目录。我遵循了这个建议,但仍然得到完全相同的错误