• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem generating JNI header file

 
Dave Robbins
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic