2

Encountered this java.lang.UnsatisfiedLinkError: Can't load AMD 64-bit .dll on a IA 32-bit platform when trying to run java file in netbeans ide. Not sure where to begin for debugging and fixing code.

Source code follows:

package demojni;
public class Main {
   static {
      System.load("C:\\Users\\Nicholas1\\Documents\\NetBeansProjects\\DemoJNI_Lib\\dist\\DemoJNI_Lib.dll"); // Load native library at runtime
                                   // hello.dll (Windows) or libhello.so (Unixes)
   }

   // Declare a native method sayHello() that receives nothing and returns void


   // Test Driver
   public static void main(String[] args) {
      new Main().sayHelloWorld();  // invoke the native method
   }
   private native void sayHelloWorld();
}
Programminghobby
  • 105
  • 1
  • 6
  • 16

3 Answers3

3

The Dll is compiled for 64 bit ( amd64 or x86_64 ) platform/cpu architecture while your windows OS/JVM/JRE installation is/are 32 bit.

Either get a 32 bit version of the dll or upgrade your working environment ( either OS or JVM/JRE installation

Sheinbergon
  • 2,875
  • 1
  • 15
  • 26
  • Great, thank you for your timely response. My Os is Windows 8 64-bit, how do I check the version of JRE. Also the JRE is 32-bit then how to upgrade just the JRE to 64-bit? – Programminghobby Apr 09 '17 at 00:15
  • I run the java -version with command prompt and it returned the version and not the xx-bit; java version "1.8.0_121" Java(TM) SE Runtime Environment (build 1.8.0_121-b13) Java HotSpot(TM) Client VM (build 25.121-b13, mixed mode, sharing) – Programminghobby Apr 09 '17 at 00:21
  • http://stackoverflow.com/questions/2062020/how-can-i-tell-if-im-running-in-64-bit-jvm-or-32-bit-jvm-from-within-a-program – Sheinbergon Apr 09 '17 at 00:28
  • Great it return "32". Now what? Do I only upgrade the JRE on my machine, and if so how? – Programminghobby Apr 09 '17 at 00:32
  • Remove the JRE installation and make sure you download the x64 version from here - http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html. Also please accept my answer once you're done :) – Sheinbergon Apr 09 '17 at 00:38
  • I went to http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html and download the "Windows x64" for "Java SE Runtime Environment 8u121". After the install was complete I ran the System.getProperty("sun.arch.data.model"); again in netbeans and it returned 32 again. I will accept your answer, but What can I do now? – Programminghobby Apr 09 '17 at 00:52
  • Make sure your netbeans IDE is not using an internal JDK. What does it say under Tools -> Java Platforms ? – Sheinbergon Apr 09 '17 at 00:55
  • Netbeans Java Platform Manager says; "JDK 1.6 (default)" under J2SE. found at C:\Program Files\Java\jdk1.6.0. What does that mean? – Programminghobby Apr 09 '17 at 00:58
  • Jesus, that's old. Change it use the one you just installed ( should be Jdk1.8*) in ProgramFiles or ProgramFiles (x86) – Sheinbergon Apr 09 '17 at 01:01
  • Yes, this is true. Netbeans will not allow me to remove jdk 1.6, I added the JDK 1.8 as a Platform, how do I change the default to JDK 1.8? – Programminghobby Apr 09 '17 at 01:06
  • Project -> (Right-Click) Properties -> Build -> Compile -> Java Platform I'd strongly advise to reinstall Netbeans and upgrade to a newer version, as I'm assuming your netbeans is as old as your jdk1.6 – Sheinbergon Apr 09 '17 at 01:10
  • What was that extention for, was it for default jdk? Also I'm upgrading my netbeans now. – Programminghobby Apr 09 '17 at 01:25
  • Do you know why the "System.getProperty("sun.arch.data.model");" is returning 32bit even after the JRE update to 64bit? – Programminghobby Apr 09 '17 at 02:10
  • Do you think the old JDK 1.6 is the issue? Do you think it could be incorrect environment variables? – Programminghobby Apr 09 '17 at 02:15
  • Finished install of Netbeans 8.2, the JDK for Netbeans location is C:\Program Files\Java\jdk1.8.0_111. Does this look right? – Programminghobby Apr 09 '17 at 02:43
  • Yep, that seems about right. your programs probably still executed under the older 1.6 JDK, that's all. – Sheinbergon Apr 09 '17 at 07:11
  • Do you know why the "System.getProperty("sun.arch.data.model");" is returning 32bit even after the JRE update to 64bit? Do you think the old JDK 1.6 is the issue? Do you think it could be incorrect environment variables – Programminghobby Apr 09 '17 at 15:35
  • Finally the "System.getProperty("sun.arch.data.model");" is returning 64bit, probably because of the JDK 1.6, How can I ensure the other programs run on the newer JDK 1.8? Wierdly enough now I cant access Project->Properties directly, I have to Project->(right click)->Set Configurations-> Customize. Could this be a bug in the new IDE? Also my java project compiling is running into a new runtime error, # A fatal error has been detected by the Java Runtime Environment: # EXCEPTION_ACCESS_VIOLATION – Programminghobby Apr 09 '17 at 16:10
0

Solved the architecture error.

Lamans explanation for Error: OS was 64-bit, I Had 64-bit compiled .dll library and a 32-bit JDK 1.6.

Solution: I updated my JAVA_HOME variable from (JDK 1.6 32-bit) to (JDK 1.8 64bit).

  • Changed Java/JRE/JDK to 64bit environment
  • Ugraded Java/JRE/JDK environment to JDK 1.8
  • Upgraded from "Netbeans 6.9.1" to "Netbeans 8.2"
  • Upgraded Netbeans "Default JDK" from "JDK 1.6" to JDK 1.8 worked.

Note: Netbeans JDK version can be found from IDE accessing Tools->Java Platforms->Platforms or use link "Changing java platform on which netbeans runs" to change default JDK for netbeans.

Programminghobby
  • 105
  • 1
  • 6
  • 16
  • What's inside ``` C:\Users\Nicholas1\Documents\NetBeansProjects\DemoJNI\hs_err_pid34736.log ``` ?. Are you able to compile your app/code and run it separately ? – Sheinbergon Apr 09 '17 at 19:02
  • Thread information, very similar to this link http://stackoverflow.com/questions/9986227/a-fatal-error-has-been-detected-by-the-java-runtime-environment-exception-acces. Some said its a JRE bug. And when I changed my Netbeans-6.9.2 IDE default JDK to JDK 1.7 I didnt get the same runtime project error. but when I changed the Netbeans-6.9.2 IDE default JDK to JDK jdk1.8.0_111 Netbeans crashes on restart. I used this link to change default JDK for Netbeans: http://stackoverflow.com/questions/2809366/changing-java-platform-on-which-netbeans-runs – Programminghobby Apr 09 '17 at 21:56
  • Here is the link to my error: http://stackoverflow.com/questions/43313847/a-fatal-error-has-been-detected-by-the-java-runtime-environment-exception-acc Right now I am able to compile and run clean/builds of my project but getting a successful run is not happening. Also my other java projects work fine. – Programminghobby Apr 10 '17 at 01:41
0

In my situaton, I just promise that Tomcat's bit was the same as the JDK's bit. I think this error doesn't matter to coding tools such as eclipse ,and bit of operating system.

Finit
  • 63
  • 8