简体   繁体   中英

Java rxtxSerial 64-bit vs. 32-bit conflict

I haven't used Java in a ridiculous amount of time, but I'm trying to cobble together a JApplet that reads from the serial port for Arduino integration. So far, it works great in NetBeans and in Eclipse, but upon building, the JNLP/JAR/HTML deployment absolutely refuses to work. The rxtxSerial.dll obtained from here (64-bit version of RXTX) has some kind of issue.

Right now the error thrown is as follows:

java.lang.UnsatisfiedLinkError: C:\Users\Scott\Documents\_School\SYSC_4917\sensor\dist\rxtxSerial.dll: Can't load AMD 64-bit .dll on a IA 32-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 sensor.Sensor.init(Sensor.java:134)
at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.init(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Now the weird thing is that my java version (1.8.0_121) is 100% 64-bit. Which means that, for some reason, Java can't link a 64-bit.dll on a 64-bit platform. Here is the output from java -version on cmd, if it helps:

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

All my environment variables and PATH and so on are all set, all the files are in the right place, and the project always runs successfully in NetBeans.

(Posted on behalf of the OP) .

EDIT: SOLVED

The solution, as suggested by user Nick Ziebert (thank you) was to uninstall and re-install Java. I had attempted this, but what I was uninstalling and reinstalling was the JDK, not the JRE. So here's what I did:

  1. Close all programs using Java -- NetBeans, Eclipse, open applets, Firefox, you name it. Restart the computer just in case.

  2. Delete all Java directories in Program Files called jre_1.X.X_XXX (I had two for some reason). Don't bother uninstalling, they won't go quietly. Note: Leave JDK alone.

  3. Re-download the.exe (Offline) Java for Windows-x64 and install it normally.

  4. Re-run JNLP, and it worked.

Anyone face this issue check rxtxSerial edition. If you try to run 32 bit edition of rxtx on 64bit JRE/JDK similar error you're gonna see.

Regardless of JDK/JRE you need to install x86 edition if you're planning to use 32 bit rxtx, which is required for serial communication. Otherwise you need to use 64 bit distribution of dll.

Re-installing the right edition will solve the issue but if you would like to save some time, just check what are the editions of java installed and check java version and JAVA_HOME . Your java home might be the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM