File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes JVM Crash within native method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "JVM Crash within native method" Watch "JVM Crash within native method" New topic
Author

JVM Crash within native method

Shitij Agarwal
Greenhorn

Joined: Dec 09, 2004
Posts: 21
Hi,

I have a simple Java file that calls a native method implemented in a .cpp file. From within the native method, I wish to get the value of a Java static field (just a hypothetical situation I'm using for my testing purposes). In order to do that, I need to find the Java class within my native method. When I use GetObjectClass, it seems to find the class, but does not find the field or method that I wish to access. When I use FindClass, it doesn't seem to find the class itself. I did some research on it, and found that this problem may be because my jvm.dll in the jre/bin/client directory may not be loaded. Is this true? Why would my FindClass fail if I have my .java, .class, and .cpp files all in the same folder?

Next, I tried to use LoadLibrary(<path to jvm.dll> from within my native method in order to load the jvm.dll file before looking for the java class using FindClass, but when I include the LoadLibrary call in my code and execute the Java program, I get the javaw.exe crash dialog box.

Could anybody please tell me why I'm not being able to tell me why my FindClass is failing, and if the reason is that jvm.dll is not loaded, how/where can I load it?

Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JVM Crash within native method
 
Similar Threads
Invocation API.
Class Loading Question
Specifying which ClassLoader gets used by FindClass()
Why getting ClassCastException?
JNI Question on Load/Unload library