> Given:
>
[quoted text clipped - 17 lines]
> So why can't it find my exception class? It's just a simple class
> derived from Exception.
Where is the class, and what does your classpath contain?
Correct me if I'm wrong, but your findClassOrDie() doesn't appear to
actually return the jclass it is declared to return. Also, it seems to
print the error message and exit unconditionally, without actually
checking whether FindClass() was successful or not. I'd suggest using
ExceptionDescribe() to see the text explaining the reason for failure,
but only when FindClass() fails (i.e. returns NULL or
ExceptionOccurred() is true).
/gordon

Signature
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Paul J. Lucas - 30 Nov 2005 08:18 GMT
> Where is the class, and what does your classpath contain?
It's in the same place (package and jar) as the class that
contains the native methods.
> Correct me if I'm wrong, but your findClassOrDie() doesn't appear to
> actually return the jclass it is declared to return.
It was a mistake in my transcription to Usenet. The function
should have been (and actually is):
jclass findClassOrDie( JNIEnv *env, char const *name ) {
jclass const theClass = env->FindClass( name );
if ( !theClass ) {
cerr << "FindClass(" << name << ") failed" << endl;
exit( 1 );
}
return theClass;
}
- Paul
Gordon Beaton - 30 Nov 2005 07:37 GMT
> It was a mistake in my transcription to Usenet. The function
> should have been (and actually is):
[quoted text clipped - 7 lines]
> return theClass;
> }
In that case, and assuming that "name" contains the correct name and
spelling of your exception class (in the form you posted at the start
of this thread), then I would start by seeing what ExceptionDescribe()
says when FindClass() fails.
Also try using some JVM arguments like -verbose:class and -verbose:jni
to see if that gives you any more clues.
Finally, re-check the classpath and location of the class...
/gordon

Signature
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e