JNI and package ..

Hello,

I'm developing an API in Java, which make call to C function via native methods.

My program works fine without pakcage.

Since I've added some "Package" command to my Java code, I've got some "java.lang.UnsatisfiedLinkError" :

Here is the output:

starting..

Library path = /usr/local/j2sdk1.4.0_01/jre/lib/i386/client:/usr/local/j2sdk1.4.0_01/jre/lib/i386:/usr/local/j2sdk1.4.0_01/jre/../lib/i386:/usr/lib

Exception in thread "main" java.lang.UnsatisfiedLinkError: cryptozen_rsa_mod_expat com.zencod.cryptozen.zenrsa.cryptozen_rsa_mod_exp(Native Method)

at com.zencod.cryptozen.zenrsa.cryptozen_rsa_mod_exp(zenrsa.java:236)

at com.zencod.cryptozen.ZEN_RSA.Crypt(ZEN_RSA.java:1540)

at com.zencod.cryptozen.ZEN_RSA.cryptBloc_doMode(ZEN_RSA.java:999)

at com.zencod.cryptozen.ZEN_RSA.engineUpdate(ZEN_RSA.java:457)

at com.zencod.cryptozen.ZEN_RSA.engineDoFinal(ZEN_RSA.java:699)

at test_cipher.main(test_cipher.java:37)

I don't undestand why I've got this error:

- my path is OK ! my library is in /usr/lib

- after adding "Package", I've recompile my source code, and redo a "javah -jni .." to have a new ".h"

- I've modified my C code

- I've installed the new library in /usr/lib

And it still not works !!

My questions are:

1) For my package, do I've to use "javah -jni com.zencod.cryptozen.zenrsa" or "javah -jni com/zencod/cryptozen/zenrsa" from the source's root ? result is not the same !

2) Do I've to use javah in the subdirectories of my package, or at the root directory of my package ? result is not the same too !

Could you help me?

* Fabien *

[1719 byte] By [pipotaza] at [2007-9-27 9:24:15]
# 1

when using javah, i use it from the root directory and use the dot notation but i am using this h file to compile c++ code that invokes the jvm. but im guessing its the same.

when you say that you have modified you c code...you mean that you have included the package name?

From the tutorial:

-

"The name of the native language function that implements the native method consists of the prefix Java_, the package name, the class name, and the name of the native method. Between each name component is an underscore "_" separator"

You might want to post some of your code, maybe someone will see something that could help. :)

-txjump

txjumpa at 2007-7-8 22:19:08 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2

Hello and thanks for your answer.

By saying "modified my C code", I mean I modified the function's name, because the name changed in .H when I'm redoing a javah .. That's all

In next days, I will do the test with using javah as you say .. and I will tell you if all is OK..

bye.

pipotaza at 2007-7-8 22:19:08 > top of Java-index,Java HotSpot Virtual Machine,Specifications...