[JNI] modification de java.library.path
Bonjour,
Le code suivant fonctionne très bien (chargement de dll pour JNI):
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| public class TestJNI1 {
public native String digit2Number(int number);
static{
System.loadLibrary("lib/madll");
System.loadLibrary("lib/jni_madll");
}
public static void main(String[] args){
TestJNI1 t = new TestJNI1();
int test = 25654;
System.out.println("Le nombre " + test + " s'écrit : \n" + t.digit2Number(test));
}
} |
(la dll jni_madll me permet uniquement d'utiliser madll avec jni sans modifier les sources)
Maintenant, j'aimerais ne pas mettre la chemin complet de la dll et y accéder grace à la variable java.library.path. Je modifie donc un peu mon code :
Code:
1 2 3 4 5 6 7
|
static{
System.setProperty("java.library.path",{REPERTOIRE D INSTALL} + "\\lib;" + System.getProperty("java.library.path"));
System.out.println(System.getProperty("java.library.path"));
System.loadLibrary("madll");
System.loadLibrary("jni_madll");
} |
La trace indique que mon répertoire qui contient mes librairies est bien dans java.library.path mais j'ai le message d'erreur suivant :
Citation:
java.lang.UnsatisfiedLinkError: no digit2Number in java.library.path
A mon avis, je modifie mal la variable java.library.path car si je mets mes librairies dans un répertoire déjà contenu dans cette variable (ex. bin de java home) alors là, le système les trouvent...