Installation de javacomm #HELP PLEASE#

ff79 Messages postés 11 Date d'inscription jeudi 8 avril 2004 Statut Membre Dernière intervention 10 octobre 2004 - 6 août 2004 à 00:22
al_b07 Messages postés 24 Date d'inscription lundi 27 septembre 2004 Statut Membre Dernière intervention 4 octobre 2004 - 27 sept. 2004 à 10:18
salut

j'ai telechargé l'api javacom.Mais y a rien qui marche!.... j'ai pourtant suivi les consignes de sun:
Copy win32com.dll to your <JDK>\bin directory.

C:\>copy c:\commapi\win32com.dll to c:\jdk1.1.6\bin

Copy comm.jar to your <JDK>\lib directory.

C:\>copy c:\commapi\comm.jar c:\jdk1.1.6\lib

Copy javax.comm.properties to your <JDK>\lib directory.

C:\>copy c:\commapi\javax.comm.properties c:\jdk1.1.6\lib
The javax.comm.properties file must be installed. If it is not, no ports will be found by the system.

Add comm.jar to your classpath (do not do this step for a JRE installation).
If you don't have a classpath defined:

C:\>set CLASSPATH=c:\jdk1.1.6\lib\comm.jar

If you already have a classpath defined:

C:\>set CLASSPATH=c:\jdk1.1.6\lib\comm.jar;%classpath%

blablabla et y a rien qui marche.
j'ai peu etre fait une bourde ds la source. j'ai recuperé celle si sur le net:
import javax.comm.*;
import java.io.*;
import java.util.*;

/*
Cette classe permet de tester les ports séries disponibles
en les listant puis en créant un stream d'entrée et de sortie
*/
public class TesteJavaComm
{
CommPortIdentifier portId;
BufferedReader in;
PrintWriter out;
SerialPort serialPort;

/*
Constructeur de la classe TesteJavaComm qui prend en paramètre le port série à utiliser.
Dans un premier temps on liste les ports disponibles sur le pc
*/
public TesteJavaComm (String com)
{
System.out.println("listage des ports série disponibles:");
listePortsDispo();
try
{
//ouverture du port série:
portId=CommPortIdentifier.getPortIdentifier(com);
serialPort=(SerialPort)portId.open("Envoi",2000);

//on sélectionne tous les paramètres de la connexion série:
serialPort.setSerialPortParams(9600,SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
System.out.println("Ouverture du port "+com);

//pour lire et écrire avec des streams:
in=new BufferedReader(
new InputStreamReader(serialPort.getInputStream()));
out=new PrintWriter(serialPort.getOutputStream());

//Teste de lecture/ecriture sur le port série

String originalText="une chaine de caractere";
outputArray = originalText.getBytes( );
out.write ( outputArray, 0 , length );
int b = in.read();
in.close();
out.close();

}
catch (Exception e)
{
e.printStackTrace();
}
}//fin constructeur

public void listePortsDispo()
{
System.err.println("recherche...");
Enumeration portList=CommPortIdentifier.getPortIdentifiers();
if (portList==null)
{
System.err.println("Aucun port de communication détecté");
return;
}
while (portList.hasMoreElements())
{
portId=(CommPortIdentifier)portList.nextElement();
System.out.println("* "+portId.getName());
} // while
} //fin de la methode listePortsDispo()

/*
Methode main qui permet de tester notre classe de teste en ouvrant une connexion sur le port COM1.
*/
public static void main(String args[])
{
new TesteJavaComm ("COM1");
}//fin du main

}//fin de la classe

resultat:
---------- Capture Output ----------
"D:\JBuilderX\jdk1.4\bin\javac.exe" TesteJavaComm.java
TesteJavaComm.java:43: cannot resolve symbol
symbol : variable outputArray
location: class TesteJavaComm
outputArray = originalText.getBytes( );
^
TesteJavaComm.java:44: cannot resolve symbol
symbol : variable outputArray
location: class TesteJavaComm
out.write ( outputArray, 0 , length );
^
TesteJavaComm.java:44: cannot resolve symbol
symbol : variable length
location: class TesteJavaComm
out.write ( outputArray, 0 , length );
^
3 errors
Terminated with exit code 1

???

merci à toi qui a pris le temps @+

1 réponse

al_b07 Messages postés 24 Date d'inscription lundi 27 septembre 2004 Statut Membre Dernière intervention 4 octobre 2004
27 sept. 2004 à 10:18
>place the win32com.dll in <jdk>\jre\bin directory.

>Place the comm.jar in <jdk>\jre\lib\ext.

>Place the javax.comm.properties in <jdk>\jre\lib

et là ça marchera, parce que j'ai déjà testé sans le jre entre et ça marche pas.
Voilà, amuse toi bien,
Et n'oublie pas, le JAVA ça déchire sa race.
0
Rejoignez-nous