I am trying to execute a dll through JNI.
I have 32 bit dll and 64 bit dll
My code works fine in a 32 bit machine(using 32 bit dll).
but it doesnt work on a 64 bit machine. I tried executing it with both 32 bit and 64 bit dll.
I also tried installing 64 bit JDK,JRE and tried to run the 64 bit dll through java.
I am getting the following error.
# A fatal error has been detected by the Java Runtime Environment:
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000006d451528, pid=956, ti
# JRE version: 6.0_21-b07
# Java VM: Java HotSpot(TM) 64-Bit Server VM (17.0-b17 mixed mode windows-amd64
# Problematic frame:
# C [java.dll+0x1528]
# An error report file with more information is saved as:
# C:\Program Files\Java\jdk1.6.0_21\bin\hs_err_pid956.log
# If you would like to submit a bug report, please visit:
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
Any idea what could be the problem.
Rob Prime wrote:Moving to Other JSE/JEE APIs.
Java VM: Java HotSpot(TM) 64-Bit Server VM (17.0-b17 mixed mode windows-amd64 )
I am pretty sure my machine is Intel. Any idea what
mixed mode windows-amd64
You need to use a 32-bit library with a 32-bit JVM, and a 64-bit library with a 64-bit JVM. If you're getting an access violation, then there's a bug in the native code. If the bug only shows up in the 64-bit version and not the 32-bit, then you're probably just lucky that it works on 32-bit. The hs_err crash report might give you a hint where the problem occurs, or it might not.
Who wrote the native code, and how big is it?
My native code is very small.
I had generated a .h file and included it in WrapperforTHEDLL.dll
WrapperforTHEDLL.dll works fine because I tried executing the exe version and it works fine everywhere(64 bit and 32 bit machine).
But as I said before my java code crashes on a 64 bit machine.
I don't know what you mean by "the exe version" -- how would you test the JNI code without the JVM? If there's some underlying functionality which you tested in C and that works fine, that's great -- but it's the JNI wrapper code that I'm more concerned about.
I actually have a 3rd party dll which has to be executed/called though java. Since i am using JNI, we created a C wrapper which will inturn call the 3rd party DLL.
I just have to call the wrapper, and it takes care of the rest. When I said "exe"; I meant, WrapperforTHEDLL.exe. I ran this in 64 bit machine and it worked fine. Of course, it wasn't the JNI code.
Since you said that problem is in wrapper; and I am not very good at C, I used JNA thus eliminating the need for wrapper. And YES!!! the code worked fine.
With a little help I was able to resolve issue in C code too.
I have the same problem with a 3rd party dll. The DLL is loaded successfully under a 32-bit machine. But under 64-bit the jvm crashes. I have tested on both 32-bit && 64-bit JVMs. Any suggestions?
Ernest Friedman-Hill wrote:You can't load a 32-bit DLL into a 64-bit JVM; you need to get a 64-bit version from the vendor.
Thanks for your response,
As I mentioned earlier I tried to load it from 32-bit JVM on 64-bit machine without success. When run on 32-bit JVM on 32-bit machine, it worked like charm.