aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes problem generating JNI header file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "problem generating JNI header file" Watch "problem generating JNI header file" New topic
Author

problem generating JNI header file

Dave Robbins
Ranch Hand

Joined: Sep 16, 2003
Posts: 131
Hello All,

I'm a newbie to JNI and I've run across a problem.
First, I went thru the standard "hello world" examlpe and it worked fine.
Next, I tried to use the same concepts in my application.
It's an applet that need to talk to a serial port thru a dll.
So, I have a package "foo", which contains an applet "bar", which has a native function "doSomething"
When I use javah to generate the header file for "doSomething" the signature is this

JNIEXPORT jstring JNICALL Java_bar_doSomething
(JNIEnv *, jobject);

when it should be this

JNIEXPORT jstring JNICALL Java_foo_bar_doSomething
(JNIEnv *, jobject);

It left out the package name
At runtime I get a linker error
I'm guessing I'm using javah wrong, anybody run across this before and have a tip for me??

Dave
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

Given a subdirectory of the current directory named "foo", containing a file named "bar.class" the command "javah foo.bar" should do the right thing. Don't have "foo" be the working directory.

This assumes that CLASSPATH is unset, or that CLASSPATH includes "." (dot), the current directory.
[ June 27, 2005: Message edited by: Ernest Friedman-Hill ]

[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem generating JNI header file