I'm new to JNI programs.. I'm trying to do a JNI program.. In that i'm getting "An unexpected error has been detected by HotSpot Virtual Machine:" error while running the code..
Can any one figure out the problem.?
I put your source into code tags. See how it is much easier to read? Also, can you tell us the EXACT and COMPLETE error message you get? Most folks here are not going to be able to compile and debug the C code, so without that information we're only kind of guessing. (this assume you didn't - I have no idea what an error like this would actually look like).
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
First of all, the class literal should not have a leading /. Secondly, this value indicates the class name is usr.jnieg.next, but I don't see a package declaration. If the class is not in a package, just use "next". Otherwise use "usr/jnieg/next".
Also, I would never use AllocObject. It "Allocates a new Java object without invoking any of the constructors for the object." I doubt that's what you need. Even if no constructor does anything, I would still use one of the NewObject functions.
Oh, and the last printf doesn't do what you think it does. It does not call toString() on the object. It instead takes the pointer value and treats it as a pointer to a string (a char*). The result is garbage.