This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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 REST with Spring (video course) this week in the Spring 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: 24195

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
jQuery in Action, 3rd edition