Problème d'execution

cs_bescherelle Messages postés 3 Date d'inscription jeudi 15 mai 2003 Statut Membre Dernière intervention 27 février 2007 - 27 févr. 2007 à 15:21
cs_bygui Messages postés 51 Date d'inscription lundi 10 avril 2006 Statut Membre Dernière intervention 16 juin 2008 - 27 févr. 2007 à 15:42
Bonjour, je n'arrive pas à compiler mes deux programmes j'ai une erreur du type java.lang.NoDefClassFoundError. Je compile ca marche et j'ai les fichiers.class correspondant. Lorque je veux executer cela ne marche pas, j'ai alors l'erreur. Je vous signale que je compile et exécute en ligne de commande sur un terminal DOS.Voici les programmes:

Serveur:
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
public class Serveur {
    private static final int BUF_SIZE = 1024;

    public static void main(String[] args) throws IOException {
        byte msg[]= new byte[BUF_SIZE];   
        DatagramSocket so= new DatagramSocket(Integer.parseInt(args[0]));
        DatagramPacket paquet= new DatagramPacket(msg, 0,msg.length);
        while(true){
        so.receive(paquet);
        String s= new String(msg,0,paquet.getLength());
        byte[] renvoi=s.toUpperCase().getBytes("ASCII");
        paquet.setData(renvoi);
        so.send(paquet);
        paquet.setData(msg);
        }    }   }

Client:
package revision;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class Client {
    private static final int BUF_SIZE = 1024;
    public static void main(String[] args) throws IOException {
        byte[] msg=args[2].getBytes("ASCII");//("ASCII");
        byte receivebuf[]= new byte[BUF_SIZE];   
        DatagramSocket so= new DatagramSocket();//creation du datagramme socket
        DatagramPacket paquet= new DatagramPacket(msg,0,msg.length,InetAddress.getByName(args[0]), Integer.parseInt(args[1]));
        System.out.println("socket attachee " + paquet.getPort());
        System.out.println("socket attachee " + so.getLocalPort());
        so.send(paquet);
        paquet.setData(receivebuf);
        so.receive(paquet);
        String s= new String(receivebuf,0,paquet.getLength(),"ASCII");
        System.out.println(s);
        so.close();
    }  }
 
Merci de votre aide

1 réponse

cs_bygui Messages postés 51 Date d'inscription lundi 10 avril 2006 Statut Membre Dernière intervention 16 juin 2008
27 févr. 2007 à 15:42
bon j'ai pas regardé ton code mais je te donne un lien pour t'aider:
http://monge.univ-mlv.fr/~roussel/RESEAUJAVA/java.udp.html
0
Rejoignez-nous