0

I use JDK (64 bit) and am using the JNA library to access a DLL. However this dll is in C: \ Windows \ SysWWOW64, so it is 64bit. How do I access it? My processor is: 64bits. My JDK is 64bits. My DLL is 64bits.

My Program:

 LibraryMethods libMethods = (LibraryMethods) Native.loadLibrary("msxfs.dll", LibraryMethods.class);

My JNA Interface:

import com.sun.jna.Library;

public interface LibraryMethods extends Library{

     public short WFSStartUp(int dwVersionsRequired, String lpWFSVersion);

}

Error:

java.lang.UnsatisfiedLinkError: %1 is not a valid Win32 application.
gavioto
  • 1,695
  • 2
  • 17
  • 38
Matheus Cardozo
  • 135
  • 1
  • 7
  • 4
    SysWOW64 is for 32 bit executables (including DLLs) see: https://msdn.microsoft.com/en-us/library/windows/desktop/aa384187(v=vs.85).aspx Specifically: _"In most cases, whenever a 32-bit application attempts to access %windir%\System32, the access is redirected to %windir%\SysWOW64"_ Note that: 64 bit / 32 bit can not load each other. – Richard Critten Jun 07 '17 at 16:30
  • what should I do? Because the DLL is 32 bits and of this error: java.lang.UnsatisfiedLinkError:% 1 is not a valid Win32 application. – Matheus Cardozo Jun 07 '17 at 16:33
  • Use a 32 bit Java VM or get a 64 bit version of the DLL – Richard Critten Jun 07 '17 at 16:33
  • @RichardCritten i have a meta question. Why do people answer clear questions in the comments? – gavioto Jun 08 '17 at 10:10
  • 1
    @gavioto Off site link in the comment to answer the question. Not enough time to properly abstract and format an answer. Get down voted for not doing the above and loose rep for an answer. – Richard Critten Jun 08 '17 at 11:36
  • @RichardCritten I think this simple responses does not requiere a lot of formating. Your response is very correct. Do you think my "oficial" answer should require a beter formating? Thank you – gavioto Jun 15 '17 at 10:55

1 Answers1

0

If the library is in SysWoW64 then it is 32 bits not 64.

So you need to use JDK 32 bits to load the DLL.

You can find more info about SysWow64 in this question

gavioto
  • 1,695
  • 2
  • 17
  • 38