老是报这个Exception in thread "main" java.lang.NoClassDefFoundError: SendDemo (wrong name: cn/itcast/udp/SendDemo) 异常,也不知道哪里错了,请哪位大侠能帮我解决一下啊!
public class SendDemo {
public static void main(String[] args) throws IOException {
DatagramSocket ds = new DatagramSocket();
byte[] bys = "Hello Java".getBytes();
InetAddress address = InetAddress.getByName("127.0.0.0.1");
DatagramPacket dp = new DatagramPacket(bys,bys.length,address,10000);
ds.send(dp);
ds.close();
}
}
public class ReceiveDemo {
public static void main(String[] args) throws IOException {
DatagramSocket ds = new DatagramSocket(10000);
byte[] bys = new byte[1024];
DatagramPacket dp =new DatagramPacket(bys,bys.length);
ds.receive(dp);
InetAddress address = dp.getAddress();
String ip = address.getHostAddress();
int port = dp.getPort();
byte[] bys2 = dp.getData();
String text = new String(bys2,0,dp.getLength());
System.out.println(ip+"***"+port+"***"+text);
ds.close();
}
}
|
|