1

I am trying to load a DLL using System.load() in Java. I get this exception:

Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Documents and Settings\dvargo\Local Settings\Temp\jmacm.dll: Can't load this .dll (machine code=0x0) on a IA 32-bit platform
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1803)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1699)
        at java.lang.Runtime.load0(Runtime.java:770)
        at java.lang.System.load(System.java:1003)
        at GlobalUtilities.DllManager.dynamicallyLoadDLL(DllManager.java:160)
        at GlobalUtilities.DllManager.dynamicallyLoadDLLs(DllManager.java:182)
        at JMFManager.JMFRunner.dynamicallyLoadJMFDllsFromResource(JMFRunner.java:152)
        at JMFManager.JMFRunner.main(JMFRunner.java:164)

What does it mean?

EDIT:

I have some dlls in my jar file. I get them out of the jar file and write them to the temp folder with the following code:


    private static ArrayList buf;
    public static InputStream soundStreams;

    public static File getResourceFile(String resourceName, File dest)
    {
        InputStream is = null;
        BufferedReader br = null;
        int line;
        ArrayList list = new ArrayList();

        try
        {
            is = new Object().getClass().getResourceAsStream(resourceName);
            br = new BufferedReader(new InputStreamReader(is));
            while (-1 != (line = br.read()))
            {
                list.add(line);
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        finally
        {
            try
            {
                if (br != null)
                {
                    br.close();
                }
                if (is != null)
                {
                    is.close();
                }

                File newFile = dest;
                newFile.createNewFile();
                FileOutputStream fos = new FileOutputStream(newFile);
                for (Integer i : list)
                {
                    fos.write(i.byteValue());
                }
                fos.close();
                return newFile;
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
        }
        return null;

    }

I then try to load this dll with System.load(); and it throws that Exception.

user489041
  • 27,916
  • 55
  • 135
  • 204

3 Answers3

5

Seems like you are trying to load a 64 bit library on a 32bit OS/JVM

dcn
  • 4,389
  • 2
  • 30
  • 39
  • Hm, I didn't want to assume anything about the library the OP was trying to load, but this is probably true. +1 – Pops Mar 18 '11 at 15:51
  • Heres the interesting part though. Im on a XP. If I put the dll in the win32 folder, it gets loaded correctly, however, if I try to load it dynamically from a folder I specify, I get this exception. – user489041 Mar 18 '11 at 15:54
  • What library is it, that you are using? – dcn Mar 18 '11 at 15:55
  • They are dlls that JMF uses. The JMF installer puts them in the Win32 folder. I want to be able to use them wherever they are. – user489041 Mar 18 '11 at 15:56
2

An UnsatisfiedLinkError is "Thrown if the Java Virtual Machine cannot find an appropriate native-language definition of a method declared native."

And, indeed, the first line under the exception there is

at java.lang.ClassLoader$NativeLibrary.load(Native Method)
Pops
  • 30,199
  • 37
  • 136
  • 151
  • ...your edit does not include a question. And why would you change the title from a question to a sentence fragment? – Pops Mar 18 '11 at 16:13
  • 1
    No, my edit does not include a question, however it does provide more information as to what I am doing that might cause the exception. And I changed the title because I want people to actually look at this post and I will get more views by using an interesting title. If I saw this title, I would be more inclined to view it. – user489041 Mar 18 '11 at 16:15
0

I received this issue when I was using a Maven project. "Can't load this .dll (machine code=0xbd) on a AMD 64-bit platform"

I disabled the Maven nature by issuing the following command to compile from the command line and then hitting F5 to refresh the project.

mvn eclipse:clean eclipse:eclipse clean compile test-compile

See http://sizustech.blogspot.com/2014/12/an-introduction-to-jni-using-bottom-up_70.html for more info.

Scott Izu
  • 2,229
  • 25
  • 12