1

I am trying to run jar for Serial Communication in Ubuntu 14.04 which requires librxtxSerial.so to be in 'jdk/bin' folder. I referred below link:

wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)

I tried with both 32-bit/64-bit librxtxSerial.so in 'jdk/bin' but is stuck with both the below error :

OpenJDK Server VM warning: You have loaded library /usr/lib/jni/librxtxSerial-2.2pre1.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
java.lang.UnsatisfiedLinkError: /usr/lib/jni/librxtxSerial-2.2pre1.so: /usr/lib/jni/librxtxSerial-2.2pre1.so: wrong ELF class: ELFCLASS64 (Possible cause: architecture word width mismatch) thrown while loading gnu.io.RXTXCommDriver
Exception in thread "main" java.lang.UnsatisfiedLinkError: /usr/lib/jni/librxtxSerial-2.2pre1.so: /usr/lib/jni/librxtxSerial-2.2pre1.so: wrong ELF class: ELFCLASS64 (Possible cause: architecture word width mismatch)
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1968)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1893)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1883)
        at java.lang.Runtime.loadLibrary0(Runtime.java:849)
        at java.lang.System.loadLibrary(System.java:1088)
        at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:83)
        at test.Test.main(Test.java:32)

Java Version : 1.7 64-bit

Ubuntu OS Release :

NAME="Ubuntu"
VERSION="14.04.1 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.1 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"

When I tried to run it with JAVA 1.8 it gave following error

Error: Could not find or load main clas test.Test (//My jar name is Test)

Janhavi Gadkari
  • 123
  • 2
  • 13
  • 1
    The error message suggests that you are using 32-bit Java and your native library is 64-bit. Are you sure you are using 64-bit Java? The "bitness" of your JVM and your native library must match, otherwise you get errors like this one. – Jesper Jul 05 '17 at 13:19
  • Show us the results of `java -version`, and also the command line you try to run. – Usagi Miyamoto Jul 05 '17 at 13:24
  • @UsagiMiyamoto cms@RDP:~/Desktop/RDPSerialCommunication$ java -version java version "1.7.0_131" OpenJDK Runtime Environment (IcedTea 2.6.9) (7u131-2.6.9-0ubuntu0.14.04.2) OpenJDK 64-Bit Server VM (build 24.131-b00, mixed mode) – Janhavi Gadkari Jul 05 '17 at 13:36
  • @UsagiMiyamoto Below is the Output: java.lang.UnsatisfiedLinkError: /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/librxtxSerial.so: /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/librxtxSerial.so: wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch) thrown while loading gnu.io.RXTXCommDriver Exception in thread "main" java.lang.UnsatisfiedLinkError: /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/librxtxSerial.so: /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/librxtxSerial.so: wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch) – Janhavi Gadkari Jul 05 '17 at 13:41
  • Ok, that last error is the opposite of what you posted in your question above: it suggests you are using 64-bit Java and your native library is 32-bit. Make sure your Java and native library have the same "bitness". – Jesper Jul 05 '17 at 13:45
  • @Jesper : how to check if native library is 32 bit or 64 bit ? – Janhavi Gadkari Jul 05 '17 at 13:51
  • 1
    You can use the `file` command, for example: `file /usr/lib/jni/librxtxSerial-2.2pre1.so`. Note that the error message tells you ELFCLASS32 or ELFCLASS64 = 32-bit or 64-bit. – Jesper Jul 05 '17 at 14:00
  • @Jesper: I copied this "librxtxSerial-2.2pre1.so" to path "/usr/lib/jvm/java-1.7.0-openjdk-amd64/jre/lib/amd64/" and "/usr/lib/jvm/java-1.7.0-openjdk-amd64/bin/" and tried to run my Test.jar. It gives me below exception now : 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 – Janhavi Gadkari Jul 06 '17 at 05:04
  • dpkg -l | grep rxtx gave me below result : ii rxtx 2.2-1.1 amd64 Parallel communication for the Java Development Toolkit – Janhavi Gadkari Jul 06 '17 at 05:29
  • Solved the error : removed all d rxtx libraries and then by coping librxtxSerial-2.2pre1.so to "/usr/lib/jvm/java-1.7.0-openjdk-amd64/jre/lib/amd64/" and RXTXComm.jar to /jre/lib/ext (64 bit) Thank you :) – Janhavi Gadkari Jul 06 '17 at 08:53
  • @JanhaviGadkari can you please give the download link for 64 bit librxtxSerial.so – Khalid Shah Nov 30 '18 at 07:57
  • @KhalidShah : [link](http://jlog.org/rxtx-lin.html) – Janhavi Gadkari Dec 03 '18 at 05:56
  • @JanhaviGadkari sorry, i want the link for 64 bit libLinuxSerialParallel.so . can you provide that ? – Khalid Shah Dec 03 '18 at 05:58

0 Answers0