Bonjour,
Dans la cadre d'un projet je dois utiliser l'API RxTx pour lire et écrire sur un port série, mais lorsque je compile le programme j'obtiens :
J'ai bien insérer le .JAR dans le projet mais apparemment c'est un problème de dll (rxtxSerial.dll et rxtxParallel.dll).
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 java.lang.UnsatisfiedLinkError?: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver Exception in thread "main" java.lang.UnsatisfiedLinkError?: no rxtxSerial in java.library.path at java.lang.ClassLoader?.loadLibrary(ClassLoader?.java:1734) at java.lang.Runtime.loadLibrary0(Runtime.java:823) at java.lang.System.loadLibrary(System.java:1028) at gnu.io.CommPortIdentifier?.<clinit>(CommPortIdentifier?.java:83) at stage.Main.listPorts(Main.java:24) at stage.Main.main(Main.java:19) Java Result: 1
J'ai cherché sur Internet et j'ai trouvé 2 solutions :
* les mettre dans /JAVA/jdk/jre/bin
* les mettre dans /Windows/System32
Pour la 1 ere j'obtiens un résultat différent mais ce n'est pas ce que mon programme devrait afficher :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 Stable Library ========================================= Native lib Version = RXTX-2.1-7 Java lib Version = RXTX-2.1-7
Voici mon code entier :
Config = Netbeans 6.9.1 sous Windows 7
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 import gnu.io.*; public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { listPorts(); } static void listPorts() { java.util.Enumeration<CommPortIdentifier> portEnum = CommPortIdentifier.getPortIdentifiers(); while ( portEnum.hasMoreElements() ) { CommPortIdentifier portIdentifier = portEnum.nextElement(); System.out.println(portIdentifier.getName() + " - " + getPortTypeName(portIdentifier.getPortType()) ); } } static String getPortTypeName ( int portType ) { switch ( portType ) { case CommPortIdentifier.PORT_I2C: return "I2C"; case CommPortIdentifier.PORT_PARALLEL: return "Parallel"; case CommPortIdentifier.PORT_RAW: return "Raw"; case CommPortIdentifier.PORT_RS485: return "RS485"; case CommPortIdentifier.PORT_SERIAL: return "Serial"; default: return "unknown type"; } } }
Merci d'avance pour votre aide =)
Partager