• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unable to execute JNI in a 64 bit machine.

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
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
d=4240
#
# 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:
# http://java.sun.com/webapps/bugreport/crash.jsp
# 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.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to Other JSE/JEE APIs.
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Prime wrote:Moving to Other JSE/JEE APIs.

When ?
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now. And thanks for pointing out my forgetfulness
 
Aparna Sree
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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

means?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"amd64" is just the name for the instruction set used by all consumer 64-bit Intel processors, because AMD were the first to define it, and Intel later had to play catch-up.

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?
 
Aparna Sree
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! for the reply.
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.
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"The native code" refers to the C language code that's in the DLL itself -- i.e., the implementation of Java_myJNIClass_myNativeEx().

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.
 
Aparna Sree
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are absolutely right!
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.

Thanks alot!
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
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
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't load a 32-bit DLL into a 64-bit JVM; you need to get a 64-bit version from the vendor.
 
Ahmed Gawad
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
reply
    Bookmark Topic Watch Topic
  • New Topic