InetAddress local = InetAddress.getByName(null);        InetAddress a = InetAddress.getByName(args[0]);

解决方案 »

  1.   

    InetAddress localip=InetAddress.getLocalHost();
    String localIp=ip.getHostAddress();             //获得本地主机ip.
    String localName=ip.getHostName();           //获得本地主机名称
      

  2.   

    检查一下InetAddress.getByName(...)中的参数是字符串吗?
      

  3.   

    package net;import java.awt.*;
    import java.applet.*;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class Net2 extends Applet {
        Panel panel1,panel2;
        TextField text1=new TextField(10);
        TextField text2=new TextField();
        TextArea  area=new TextArea(7,10);
        Label label=new Label("请输入对方IP");
        Button ok=new Button("确定");
        Button button=new Button("发送");
        InetAddress address;
        
        DatagramSocket socket;
        byte[] obuf=new byte[10240];
        byte[] ibuf=new byte[10240];
        DatagramPacket out;
        DatagramPacket in=new DatagramPacket(ibuf,ibuf.length);
    public void init() {
             .....
                      .....
                      
                     show();
       } public boolean action(Event evt,Object args){
        if((evt.target==button)){
         area.append('\n'+"我说:"+text2.getText());
         text2.setText("");     }
    if ((evt.target==ok)||(text1.getText()!=null)){
                     address=InetAddress.getByName(text1.get()):
                     ......
                     ......
    }
    return true;}}问题就在最后那里
      

  4.   

    >> address=InetAddress.getByName(text1.get()):
                                     ^^^^^^^^^^^ 
                                     有这个方法吗? text1.getText()吧?
      

  5.   

    不明白,我的也是那样的,没有错误阿
    address=InetAddress.getByName(text1.get()):
    最后改成分号,你的是冒号