File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "problem generating JNI header file" Watch "problem generating JNI header file" New topic

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??

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Given a subdirectory of the current directory named "foo", containing a file named "bar.class" the command "javah" 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:
subject: problem generating JNI header file
It's not a secret anymore!