Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/03/2004, 06:58
chcma
 
Fecha de Ingreso: junio-2003
Ubicación: Asturias
Mensajes: 2.429
Antigüedad: 20 años, 11 meses
Puntos: 7
Problema al compilar un ejercicio.

Buenas tardes.

Para empezar, yo sé algo de java, no mucho, pero algo se.

Ahora verán, quiero hacer un chat en java y necesito usar un servidor de sockets que está creado en java. El servidor me lo baje de aqui:

www.moock.org/chat/moock.Comm.zip

Y lo descomprimi en la carpeta bin de mi j2sdk, apareciendome los siguientes ficheros:

CommServer.class
CSClient.class
CSTestClient.class

Pues bien, al ejecutar el CommServer.class, que es el que dicen que tengo que ejecutar, me salta el siguente error:

java CommServer

Exception in thread "main" java.lang.NoClassDefFoundError: CommServer

Y el codigo de este .class es el siguiente:






*/
public synchronized void broadcastMessage(String message) {
// --- add the null character to the message
message += '\0';

// --- enumerate through the clients and send each the message
Enumeration enum = clients.elements();
while (enum.hasMoreElements()) {
CSClient client = (CSClient)enum.nextElement();
client.send(message);
}

}

/**
* Removes clients from the client list.
* @param client The CSClient to remove.
*/
public void removeClient(CSClient client) {
writeActivity(client.getIP() + " has left the server.");

// --- remove the client from the list
clients.removeElement(client);

// --- broadcast the new number of clients
broadcastMessage("<NUMCLIENTS>" + clients.size() + "</NUMCLIENTS>");
}

/**
* Writes a message to System.out.println in the format
* [mm/dd/yy hh:mm:ss] message.
* @param activity The message.
*/
public void writeActivity(String activity) {
// --- get the current date and time
Calendar cal = Calendar.getInstance();
activity = "[" + cal.get(Calendar.MONTH)
+ "/" + cal.get(Calendar.DAY_OF_MONTH)
+ "/" + cal.get(Calendar.YEAR)
+ " "
+ cal.get(Calendar.HOUR_OF_DAY)
+ ":" + cal.get(Calendar.MINUTE)
+ ":" + cal.get(Calendar.SECOND)
+ "] " + activity + "\n";

// --- display the activity
System.out.print(activity);
}

/**
* Stops the server.
*/
private void killServer() {
try {
// --- stop the server
server.close();
writeActivity("Server Stopped");
} catch (IOException ioe) {
writeActivity("Error while stopping Server");
}
}


public static void main(String args[]) {
// --- if correct number of arguments
if(args.length == 1) {
CommServer myCS = new CommServer(Integer.parseInt(args[0]));
} else {
// otherwise give correct usage
System.out.println("Usage: java CommServer [port]");
}
}
}





En fin, espero que puedan ayudarme, despues de todo el rollo que les solte.

Desde ya Gracias a todos por la ayuda ofrecida aqui.
__________________
Charlie.