How to run an API made for 32-bit on a 64-bit machine?
Asked Answered
S

5

8

I'm writing a java application which has to communicate with has to communicate with an XBee radio over a usb-cable.To do this , I use the xbee-java API (http://code.google.com/p/xbee-api/)

On my old 32-bit machine it all worked fine . But when I imported the project to a 64-bit machine , it throws immediately an exception which says :" Can't load IA 32-bit .dll on a AMD 64-bit platform" . I don't have any idea how I can solve this problem .

the error code :

    java.lang.UnsatisfiedLinkError: C:\Users\Tom\Documents\XbeeJava\rxtxSerial.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform thrown while loading gnu.io.RXTXCommDriver
Closing connection with local XBee
Exception in thread "Thread-1" java.lang.UnsatisfiedLinkError: C:\Users\Tom\Documents\XbeeJava\rxtxSerial.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(Unknown Source)
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:83)
    at com.rapplogic.xbee.RxTxSerialComm.openSerialPort(RxTxSerialComm.java:71)
    at com.rapplogic.xbee.RxTxSerialComm.openSerialPort(RxTxSerialComm.java:61)
    at com.rapplogic.xbee.api.XBee.open(XBee.java:140)
    at me.server.HardwareCommunications.SensorListener.run(SensorListener.java:47)
    at java.lang.Thread.run(Unknown Source)

Thanks , Tom

Stott answered 21/2, 2012 at 14:13 Comment(0)
E
9

It is not possible to load a 32-bit DLL into a 64-bit process.

Based on the description, the JVM you are running is 64-bit but the DLL rxtxSerial.dll is 32-bit. To resolve, either:

  • Obtain 64-bit rxtxSerial.dll, or
  • Install and use 32-bit JVM with the current rxtxSerial.dll
Espinoza answered 21/2, 2012 at 14:18 Comment(0)
E
6

A 64-bit executable (and process) (your Java VM) can only use 64 bit DLLs.

But you could download, install and run a 32-bit version of Java. Unless you also need to access 64 bit DLLs or need more than 2 to 3 GB of memory, the 32 bit Java VM will run fine on a 64 bit machine.

Eous answered 21/2, 2012 at 14:19 Comment(0)
T
5

You can get the 64 bit dlls for rxtx here: http://www.cloudhopper.com/opensource/rxtx/

Taken answered 21/2, 2012 at 14:31 Comment(0)
A
1

It seems that your XBee Library relies on JNI to call some native code embedded in a DLL.

you cannot link this DLL within a 64Bit Java Virtual Machine, and that's normal.

So, you'll have either: - to recompile XBee if you have access to the source code. - to get a 64Bit distribution of the API

Use a Java 32Bit VM to execute your code.

Acidulent answered 21/2, 2012 at 14:20 Comment(0)
M
1

Check https://github.com/NeuronRobotics/nrjavaserial

It includes several native libraries inside the jar (windows, linux, mac, 32 and 64) and load them automatically so you forget about telling JVM where to find them

Myrmidon answered 23/11, 2015 at 10:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.