This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes JNI with parameters on Linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "JNI with parameters on Linux" Watch "JNI with parameters on Linux" New topic
Author

JNI with parameters on Linux

paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20494
    ∞


Well, I got JNI to work fine on Linux as long as I don't do anything interesting.
I'm now trying to pass in a string and get a string back. My java program takes a string from the command line and sends it to the JNI. The JNI reverses the string and returns it. The java program prints the results.
If I run the program with no parameters, I get the default message. If I pass a parameter, I get some sort of crash. Here is what I have:

Can anyone tell me what I'm doing wrong?


permaculture Wood Burning Stoves 2.0 - 4-DVD set
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20494
    ∞

To answer my own question ...
I change the value of s before passing it back to ReleaseStringUTFChars(), so it has no idea what to release.
It turns out that there was a second flaw in the c program: I was returning buffy instead of s.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JNI with parameters on Linux
 
Similar Threads
Tomcat hanging on shutdown
Thread dump - thread states
main app won't stop when all threads are done running
how to get Thread dumps
Multithreading and Memory Management