Java.lang.UnsatisfiedLinkError: no usbJava in java.library.path

I am trying to connect to my arduino with Java and OSx yosemite but I get the following error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no usbJava in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1865)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1122)
    at ch.ntb.usb.LibusbJava.<clinit>(LibusbJava.java:366)
    at ch.ntb.usb.USB.init(USB.java:315)
    at org.zu.ardulink.connection.usb.DigisparkUSBConnection.getPortList(DigisparkUSBConnection.java:116)
    at org.zu.ardulink.Link.getPortList(Link.java:217)
    at BlinkLED.main(BlinkLED.java:36)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

      

This is the code I am executing:

public static void main(String[] args) {
        try {
            Link link = Link.getDefaultInstance();
            link = getDigisparkConnection(); // Comment this row if you use just the default connection

            List<String> portList = link.getPortList();
            if(portList != null && portList.size() > 0) {
                String port = portList.get(0);
                System.out.println("Connecting on port: " + port);
                boolean connected = link.connect(port);
                System.out.println("Connected:" + connected);
                Thread.sleep(2000);
                int power = IProtocol.HIGH;
                while(true) {
                    System.out.println("Send power:" + power);
                    link.sendPowerPinSwitch(2, power);
                    if(power == IProtocol.HIGH) {
                        power = IProtocol.LOW;
                    } else {
                        power = IProtocol.HIGH;
                    }
                    Thread.sleep(2000);
                }
            } else {
                System.out.println("No port found!");
            }

        }
        catch(Exception e) {
            e.printStackTrace();
        }
    }

    private static Link getDigisparkConnection() {
        Set<String> protocolNames = ProtocolHandler.getInstalledProtocolImplementationNames();
        SimpleBinaryProtocol protocol = new SimpleBinaryProtocol();
        if(!protocolNames.contains(SimpleBinaryProtocol.NAME)) {
            ProtocolHandler.installProtocolImplementation(protocol);
        }
        return Link.createInstance("digisparkConnection", SimpleBinaryProtocol.NAME, new DigisparkUSBConnection("digisparkConnection", protocol.getIncomingMessageDivider()));
    }

      

When I comment out the fourth line (link = getDigisparkConnection ();) I get the following error:

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(ClassLoader.java:1865)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1122)
    at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:83)
    at org.zu.ardulink.connection.serial.SerialConnection.connect(SerialConnection.java:161)
    at org.zu.ardulink.connection.serial.SerialConnection.connect(SerialConnection.java:139)
    at org.zu.ardulink.connection.serial.SerialConnection.connect(SerialConnection.java:227)
    at org.zu.ardulink.Link.connect(Link.java:187)
    at BlinkLED.main(BlinkLED.java:37)

      

It has something to do with the native rxtx lib, but I can't seem to solve it. I am using IntelliJ IDEA as IDE. Looking for this error, I only found answers on Linux, but didn't say anything about OSX. Thanks to

+3


source to share





All Articles