I was addicted to using RXTX on Sierra

A story I was addicted to when trying to serially communicate with Arduino using Eclipse on macOS Sierra.

Execution environment

RXTX

Overview

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

Download rxtx-2.1-7-bins-r2.zip on the following page http://rxtx.qbang.org/wiki/index.php/Download

Move files

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

Pass through eclipse

  1. In eclipse, right-click the current project folder-> [Properties]
  2. [Java Build Path]-> [Library]
  3. [Add External JAR]-> Select RXTXcomm.jar in the Extensions directory.
  4. Select the Extensions directory for [Native Library Location] in RXTXcomm.jar that appears in [JAR and Class Folders on Build Path].
  5. OK

Run

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.

It was a version issue

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/

Run again

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.

Conclusion

The library file downloaded from the official page did not support the new Java version.

Reference page

Recommended Posts

I was addicted to using RXTX on Sierra
What I was addicted to while using rspec on rails
I was addicted to installing Ruby/Tk on MacOS
I was addicted to starting sbt
I was addicted to looping the Update statement on MyBatis
I was addicted to using Java's Stream API in Scala
I was addicted to rewriting to @SpringApplicationConfiguration-> @SpringBootTest
I was addicted to the roll method
I was addicted to the Spring-Batch test
A note when I was addicted to converting Ubuntu on WSL1 to WSL2
[Rails] I was addicted to the nginx settings when using Action Cable.
A story I was addicted to when testing the API using MockMVC
I was addicted to doing onActivityResult () with DialogFragment
I was addicted to the NoSuchMethodError in Cloud Endpoints
I was addicted to the record of the associated model
A story I was addicted to when getting a key that was automatically tried on MyBatis
What I was addicted to when introducing the JNI library
What I fixed when updating to Spring Boot 1.5.12 ・ What I was addicted to
I was addicted to setting default_url_options with Rails devise introduction
A story I was addicted to in Rails validation settings
I was addicted to the setting of laradock + VSCode + xdebug
What I was addicted to with the Redmine REST API
The story I was addicted to when setting up STS
A story I was addicted to before building a Ruby and Rails environment using Ubuntu (20.04.1 LTS)
Android memo-I was addicted to Permission
[Circle CI] A story I was addicted to at Start Building
I just want to write Java using Eclipse on my Mac
What I was addicted to when implementing google authentication with rails
About the matter that I was addicted to how to use hashmap
I tried to display the calendar on the Eclipse console using Java.
I was addicted to the API version min23 setting of registerTorchCallback
Memorandum: What I was addicted to when I hit the accounting freee API
A story that I was addicted to twice with the automatic startup setting of Tomcat 8 on CentOS 8
My.cnf configuration problem that I was addicted to when I was touching MySQL 8.0 like 5.7
I want to display background-ground-image on heroku.
I was addicted to a simple test of Jedis (Java-> Redis library)
Problems I was addicted to when building the digdag environment with docker
Recorded because I was addicted to the standard input of the Scanner class
I was a little addicted to running old Ruby environment and old Rails
I want to install PHP 7.2 on Ubuntu 20.04.
I was addicted to scrollview because I couldn't tap the variable size UIView
[CircleCI] I was addicted to the automatic test of CircleCI (rails + mysql) [Memo]
I was a little addicted to ssh connection from mac to linux (ubuntu)
I tried to build AdoptOpenjdk 11 on CentOS 7
I was addicted to unit testing with the buffer operator in RxJava
I was addicted to not being able to connect to AWS-S3 from the Docker container
I was a little addicted to the S3 Checksum comparison, so I made a note.
SpringSecurity I was addicted to trying to log in with a hashed password (solved)
I tried using Junit on Mac VScode Maven
I tried to implement a server using Netty
What I was addicted to when developing a Spring Boot application with VS Code
A memo that I was addicted to when making batch processing with Spring Boot
When making a personal app, I was wondering whether to make it using haml
The CSV file that I was able to download suddenly started to appear on the page.
The part I was addicted to in "Introduction to Ajax in Java Web Applications" of NetBeans
A memorandum because I was addicted to the setting of the Android project of IntelliJ IDEA
What I was addicted to when trying to properly openAPI/Swagger documentation with Rails + Grape + Grape Swagger
I want to implement it additionally while using kotlin on a site running Java
I want to use NetBeans on Mac → I can use it!
I built an Ubuntu environment on Windows 10 using WSL2.
I tried to operate SQS using AWS Java SDK