Bonjour j'essai d'apprendre à utiliser JNA.

J'ai fait un petit programme bidon en c (testé avec JNI et ca fonctionne).

Je veux maintenant utiliser la dll avec du jna:

Voici le code
TestJNAInterface :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import com.sun.jna.*;
 
 
 
public interface TestJNAInterface extends Library {	
 
 
	TestJNAInterface INSTANCE = (TestJNAInterface)Native.loadLibrary("testJNI", TestJNAInterface.class);
 
 
 
	public int addition(int a, int b);
	public void testJni();
	public String concat(String a , String b);
et
TestJNAImpl:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
 
public class TestJNAImpl {
 
	public  static void main(String[] argv){
		TestJNAInterface lib = TestJNAInterface.INSTANCE;
 
		lib.testJni();
	}
 
}

j'obtiens une exception qui est la suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'testJNI': Le module spécifié est introuvable.
 
	at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:163)
	at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:236)
	at com.sun.jna.Library$Handler.<init>(Library.java:140)
	at com.sun.jna.Native.loadLibrary(Native.java:379)
	at com.sun.jna.Native.loadLibrary(Native.java:364)
	at TestJNAInterface.<clinit>(TestJNAInterface.java:8)
	at TestJNAImpl.main(TestJNAImpl.java:5)
du coup j'ai tester en mettant le path complet de la dll
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import com.sun.jna.*;
 
 
 
public interface TestJNAInterface extends Library {	
 
 
	TestJNAInterface INSTANCE = (TestJNAInterface)Native.loadLibrary("C:/Users/binot/Desktop/HubOptLiaison/testJNI_JNA/worspace/TestJNA/lib/testJNI", TestJNAInterface.class);
 
 
 
	public int addition(int a, int b);
	public void testJni();
	public String concat(String a , String b);
le resultat est une autre exception:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'testJni': La procédure spécifiée est introuvable.
 
	at com.sun.jna.Function.<init>(Function.java:179)
	at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:344)
	at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:324)
	at com.sun.jna.Library$Handler.invoke(Library.java:203)
	at $Proxy0.testJni(Unknown Source)
	at TestJNAImpl.main(TestJNAImpl.java:7)

Quel est l'erreur ? merci d'avance