aspose file tools*
The moose likes Java in General and the fly likes Calling Java from C (JNI) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Calling Java from C (JNI)" Watch "Calling Java from C (JNI)" New topic
Author

Calling Java from C (JNI)

Matt Senecal
Ranch Hand

Joined: Dec 01, 2000
Posts: 255
I have a java class that contains a method I need to make accessable to C functions. It looks something like this:

Using javah I have my ExportName.h, and I'm in the process of writing ExportName.c:

I have 2 questions:
(1)At some point, I need to actually call the java method using

What type should I use here (CallWhatMethod)?
(2)Also, I need to create genuine C wrappers for these methods. How do I hand off the jstring returned by this JNI C code to the ANSI C method that calls it? I know that there is a conversion along the lines of:

Can I just put the call to the JNI code where the jstring variable name goes?
Any help would be appreciated. I have already read the Java tutorial on JNI, so please don't respond just to tell me to go there.
Thanks!
[ May 13, 2002: Message edited by: Matt Senecal ]

There's nothing more dangerous than a resourceful idiot. ---Dilbert
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling Java from C (JNI)