JNI with packages

S

stixwix

Hi,

I have a java program using JNI that works fine when in the default
(none) package.
If I have a directory called test:
The java code sits in this dir and I compile it from here.
I then run javah which creates the header file in this dir.
I then ggc the c code from here.
- it's all fine.

But in the real world this should be in a package so lets say the java
code goes in a a sub-dir of test called child.
The java code sits in this child dir and I compile it from here.
I change dir to the parent test dir.
I then run javah -jni which creates the header file in this dir (the
header file is now called child_xxx).
I then ggc the c code from here (after editing for the new header file
name).
- I get java.lang.UnsatisfiedLinkError: at the line number that i
call the native method in my java code.
The shared object remains exported as it was for the first working
attempt and I load the lib in the same way in the java code.
What gives...?
Thanks,
Andy
 
C

Chris Uppal

stixwix said:
I then ggc the c code from here (after editing for the new header file
name).
- I get java.lang.UnsatisfiedLinkError: at the line number that i
call the native method in my java code.
The shared object remains exported as it was for the first working
attempt and I load the lib in the same way in the java code.

What OS ?

-- chris
 
G

Gordon Beaton

I then run javah -jni which creates the header file in this dir (the
header file is now called child_xxx).

Did you provide the fully qualified classname (i.e.
my.package.MyClass) when you ran javah? Did you make the appropriate
changes to the names of the functions in your native source file?

/gordon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,137
Latest member
NoelAshwor
Top