digidotcom / xbee-java

Set of Java APIs to interact with Digi International's XBee radio frequency modules.
Mozilla Public License 2.0
80 stars 56 forks source link

java.lang.IllegalArgumentException: rxtx.native: Invalid module name: 'native' is not a Java identifier #157

Open christianitis opened 3 years ago

christianitis commented 3 years ago

You can probably guess what the problem is here. I am forced to modularize my project because I am using JavaFX, but I get this error: Error occurred during initialization of boot layer java.lang.module.FindException: Unable to derive module descriptor for /home/user/.m2/repository/org/rxtx/rxtx-native/2.2/rxtx-native-2.2-linux_x86_64.jar Caused by: java.lang.IllegalArgumentException: rxtx.native: Invalid module name: 'native' is not a Java identifier I realize this is probably an RXTX problem, but that repo hasn't been touched in around a decade so I don't expect a fix from them. My module-info.java has requires xbee.java.library (obviously). Does anyone have a workaround for this? The obvious answer is to make my project non-modular, but JavaFX requires modularity so I'm kinda stuck between a rock and a hard place here. I'm on Java 11.

msoldin commented 2 years ago

First you need to install the libraries locally to your maven repository, because they are not in the online maven repository anymore:

mvn install:install-file -Dfile="libs/rxtx-2.2.jar" -DgroupId="org.rxtx" -DartifactId="rxtx" -Dversion="2.2" -Dpackaging="jar" -DgeneratePom="true"
mvn install:install-file -Dfile="libs/xbee-java-library-1.3.0.jar" -DgroupId="com.digi.xbee" -DartifactId="xbee-java-library" -Dversion="1.3.0" -Dpackaging="jar" -DgeneratePom="true"

On linux you also have to install the native library

apt-get install librxtx-java

Another problem for me is that the library is crashing on jdk11, it is because newer java versions only support 64 bit by default. The rxtx-library is crashing, because the default java 8 installation was 32 bit. You can install a java11 jdk from https://adoptopenjdk.net/releases.html with 32 bit to solve this problem. Another solution would be replacing the rxtx library with nrjavaserial, but this requires some work todo.

That was everything for me to get it running on my machine.