简体   繁体   中英

Java Console not working: Can't load IA 32-bit .dll on a AMD 64-bit platform

So I have Eclipse 3.7.1, running on a 64-bit Windows 7 OS. For the first time in a while yesterday I tried writing a program and kept getting the above error. I refined my program down to a bare minimum beginners tutorial and was still getting the error. My program now is a simple readInt()s and add them together.

The code:

import acm.program.*;

public class DBEditor extends ConsoleProgram {

public void main() {
     System.out.println("This adds two integers");
     int a = readInt("First Num: ");
     int b = readInt("Second Num: ");
     int total = a+ b;
     System.out.println("The sum of the numbers is: " + total);
}

}

the error when trying to run as Java Application:

Exception in thread "main" java.lang.UnsatisfiedLinkError: 
C:\Users\scarr\GCMDLN.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.load0(Unknown Source)  
    at java.lang.System.load(Unknown Source)    
    at acm.program.DOSCommandLine.getCommandLine(Program.java)  
    at acm.program.Program.getCommandLine(Program.java)     
    at acm.program.Program.main(Program.java)

How do i fix this? I am fairly rusty, so the more detailed step by step fix, the better. Thanks in advance.

Clearly the error you're getting is because something in your code tries to load a native library (DLL) and the library you have is for 32 bit Windows while you're running in 64 bit.

Take a look at the DosCommandLine.getCommandLine() method in Program.java for clues. If you absolutely need functionality provided by that library then you could download the 32 bit JRE and try to run it with it.

Switching to the 32 bit JRE when executing works for me. Below are the steps on how to do this exactly in Eclipse:

  • Go to Run
  • Go to Run configurations
  • Under the JRE tab you can switch to the 32 bit JRE

The issue is because you are using a .dll file for a 32bit version, while your JDK and platform are 64bit. Go to your path "C:\\Users\\scarr" and you will find 2 subfolders, i386, and x64. Copy the GCMDLN.DLL from the x64 or the current .dll file, to override it. I think the issue will be solved.

I ran in the same problem with a wrong declaration of the main or run method. In standard java:

public static void main(String [] args) {
}

Using ConsoleProgram from the acm library I think you should be:

public void run() {
}

So run() Instead of main() . So nothing to do with the 64bit jre .

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