also put it in: java.library.path to see if it can fix the problem.
also
export LD_LIBRARY_PATH java.library.path
Main Topics
Browse All TopicsI'm trying to run some java code on Solaris 10, but I get the java.lang.UnsatisfiedLinkE
I have updated the path LD_LIBRARY_PATH to contain the path of where the .so file resides. For example
my libTestLib.so resides in /export/home/smyatt/TestAp
My programs throws the exception whenever it tries to call on of the native methods.
Any suggestion as to what I am missing?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Well, then move to the next checks :-)
UnsatisfiedLinkError usually occurs when:
--> the library can't be found (not the case),
--> native function declarations aren't what they should be (most likely this is the reason)
--> a C compiler has mangled the exported names of functions in the library (check the lib with nm)
I'm just gonna lay out my setup and my code and see if you see anything.
*********** MyTestCore.java **************
package com.Tester.MyTest;
public class MyTestCore {
private native String Function1(String inputValues);
private native void Load(String filePath);
private native long Function2(String inputA, String inputB);
public MyTestCore (String filePath)
{
this.Load(filePath); //throws the error here saying it can't find Load
}
public String RunFunction1(String inputValues)
{
return this.Function1(inputValues
}
public double RunFunction2(String inputA, String inputB)
{
return this.Function2(inputA,inpu
}
static
{
System.out.println(System.
System.loadLibrary("TestCo
}
}
*********** MyTestCore.h **************
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class MyTestCore */
#ifndef _Included_MyTestCore
#define _Included_MyTestCore
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: MyTestCore
* Method: Function1
* Signature: (Ljava/lang/String;)Ljava/
*/
JNIEXPORT jstring JNICALL Java_MyTestCore_Function1
(JNIEnv *, jobject, jstring);
/*
* Class: MyTestCore
* Method: Load
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_MyTestCore_Load
(JNIEnv *, jobject, jstring);
/*
* Class: MyTestCore
* Method: Function2
* Signature: (Ljava/lang/String;Ljava/l
*/
JNIEXPORT jlong JNICALL Java_MyTestCore_Function2
(JNIEnv *, jobject, jstring, jstring);
#ifdef __cplusplus
}
#endif
#endif
**************************
************ TestCore.cpp **************
#include <iostream>
#include <jni.h>
#include "MyTestCore..h"
using namespace std;
JNIEXPORT jstring JNICALL Java_MyTestCore_Function1(
{
//some code
}
JNIEXPORT void JNICALL Java_MyTestCore_Load(JNIEn
{
//some code
}
JNIEXPORT jlong JNICALL Java_MyTestCore_Function2 (JNIEnv *env, jobject, jstring inputA, jstring inputB)
{
//some code
}
**************************
One thing I thought might be the problem was: Where I call System.loadLibrary("TestCo
Thanks for the help.
I've tried compiling it two different ways:
javah -classpath /export/home/smyatt/Tester
the above way would give me Java_com_Tester_MyTest_MyT
but it also compiles if i do:
javah -classpath /export/home/smyatt/Tester
which gives me the shorter declarations that I posted earlier.
Maybe that's the problem.
On a side note I tried removing all package headings and just placed all of the code in the same folder and it worked properly. So it must be something with my directory paths and/or packages.
Business Accounts
Answer for Membership
by: florin_ganeaPosted on 2008-02-20 at 15:55:51ID: 20943467
The native lib should be loaded in the static part of the class with native functions.
And the library name should be without ".so".