A story I was addicted to when trying to serially communicate with Arduino using Eclipse on macOS Sierra.
RXTX
A library for serial communication with microcomputers such as Arduino. Windows, Mac and Linux are supported. I proceeded with reference to the following page. http://cho-kotan.blogspot.jp/2012/10/javaavrmacjavaavr.html
Download rxtx-2.1-7-bins-r2.zip
on the following page
http://rxtx.qbang.org/wiki/index.php/Download
Extract the downloaded file and move the downloaded file to the folder for the external library by the following command.
$ cd <download_folder>/rxtx-2.1-7-bins-r2
$ sudo cp RXTXcomm.jar /Library/Java/Extensions/
$ sudo cp Mac_OS_X/librxtxSerial.jnilib /Library/Java/Extensions/
Also, since a directory for exclusive control of RXTX is required, execute the following command.
$ sudo mkdir /var/lock
$ sudo chmod 777 /var/lock
RXTXcomm.jar
in the Extensions directory.Copy and paste the source code of the following URL that you referred to and execute it as it is. http://cho-kotan.blogspot.jp/2012/10/javaavrmacjavaavr.html
Then, the following error
java.lang.UnsatisfiedLinkError: /Library/Java/Extensions/librxtxSerial.jnilib: dlopen(/Library/Java/Extensions/librxtxSerial.jnilib, 1): no suitable image found. Did find:
/Library/Java/Extensions/librxtxSerial.jnilib: no matching architecture in universal wrapper thrown while loading gnu.io.RXTXCommDriver
I'm getting an error about the link, but I'm angry that I got an error while reading gnu.io.RXTXcommDriver
, so it seems that the path is working properly.
It didn't work no matter how many times I tried it, so I investigated it.
I didn't know if it wasn't supported by Sierra or java, so I searched variously and found the following page. http://blog.brianhemeryck.me/installing-rxtx-on-mac-os-mountain-lion/
According to the article, it seems that the file librxtxSerial.jnilib
downloaded from the official page only supports Java 5, and similar errors may occur in Java 6 and later from Mountain Lion (Eclipse). It may depend on the environment ...).
Therefore, delete the librxtxSerial.jnilib
from the Extensions file, and download the Java 6 compatible one on the following page.
http://blog.iharder.net/2009/08/18/rxtx-java-6-and-librxtxserial-jnilib-on-intel-mac-os-x/#comment-163295
$ rm /Library/Java/Extensions/librxtxSerial.jnilib
$ cp <download_folder>/librxtxSerial.jnilib /Library/Java/Extensions/
Since the path of the external JAR file has been set in Eclipse in the previous setting, execute it in Eclipse as it is when the above command is completed.
The value read from Arduino was displayed on the console safely.
The library file downloaded from the official page did not support the new Java version.
Recommended Posts