We help IT Professionals succeed at work.

unsatisfied link error

ramalaks
ramalaks asked
on
I have package, which have few java files and one of them loads a C library, to call a function.  when I run,
the library is loaded properly, but, when the native function is called, it throws an run time exception
"unsatisfiledLinkError" with that native function.
any idea why?

but the same program works, if do not have a package,
put all the java files in one dir, complie and put the classes in the same dir, and run.
Comment
Watch Question

Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
SOunds like you've added a package to your file afer you generated your JNI stubs.
Regenerate your JNI signatures.

Author

Commented:
I have tried regenerating javah -jni and build new lib with that. still not happy.

Author

Commented:
my javah -jni output does not have the pkg name added in the signature. like Java_pkg_classname_methodname

I just have Java_classname_methodname even after i added the package and redid the javah?

why? i think this is was is creating problem. any suggestions?
Java Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
Did you specify the fully qualified classname when u ran javah?

Author

Commented:
That was my problem. I did not specfiy the fully classname with the pkg when i ran javah. Now it is Ok.
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
> That was my problem

Then why the 'C' :-)

Thanks for the points.

Commented:
hi
i am usnig bridge2java to generate java proxies from the DLL
and when i try to call it in the java application i get this error
Exception in thread "main" java.lang.UnsatisfiedLinkError: CreateObjectB2J  
at com.ibm.bridge2java.Dispatch.CreateObjectB2J(Native Method)
at com.ibm.bridge2java.Dispatch.<init>(Dispatch.java:35)
at msxml4.IXMLDOMDocument2.<init>(IXMLDOMDocument2.java:17)
at msxml4.DOMDocument40.<init>(DOMDocument40.java:11)
at a.main(a.java:12)

i feel its a problem with the  location of my .class files and DLLs

can anyone help

Thanks
Kumar

Author

Commented:

1.
did you create your .h (javah) from outside the package
structure.

if you hava pkg, com.ibm.bridge2java.Dispatch.xxx.class
you should do javah from one level up from directory com.
as javah -jni com.ibm.bridge2java.Dispatch.xxxx

2. looks like your path (LD_LIBRARY_PATH) is set properly.
otherwise you will have problem in loading the library itself.  

3. See if the method signature is correct.

you have to ask the question as a new question as this one is closed already.

Thanks

Explore More ContentExplore courses, solutions, and other research materials related to this topic.