帮我看看好吗

vigirl 2003-04-13 11:34:32
// 文件名为 NetTool.java
import java.net.*;
public class NetTool{
InetAddress myIPaddress=null;
InetAddress myServer=null;
public static void main( String args[]){
NetTool mytool;
mytool=new NetTool();
System.out.println("Your host IP is: "+ mytool.getMyIP());
System.out.println("The Server IP is :"+mytool.getServerIP());
}
//取得LOCALHOST的IP地址
public InetAddress getMyIP() {
try { myIPaddress=InetAddress.getLocalHost();}
catch (UnknownHostException e) {}
return (myIPaddress);
}
//取得 www.abc.com 的IP地址
public InetAddress getServerIP(){
try {myServer=InetAddress.getByName("www.163.com");}
catch (UnknownHostException e) {}
return (myServer);
}
}

这是ping ip的程序,为什么运行是总说我缺少主要的类啊,帮我看看有没什么错误
...全文
56 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
superLee 2003-04-15
  • 打赏
  • 举报
回复
恭喜!
vigirl 2003-04-14
  • 打赏
  • 举报
回复
已经好了,莫名其妙的好了,谢谢各位了~呵呵
XBulletin 2003-04-14
  • 打赏
  • 举报
回复
程序是正确的,应该是classpath的问题,仔细检查一下,

GOOD LUCK!
lmszcm 2003-04-14
  • 打赏
  • 举报
回复
classpath设置有错误,如果没错的话,重启计算机再运行
mercury1231 2003-04-14
  • 打赏
  • 举报
回复
这么简单的一个程序,,真是看不出错在什么地方,
我觉得可能是你的路径设置有问题吧。最好把错误贴出来让大家看一下。
kkill 2003-04-14
  • 打赏
  • 举报
回复
程序没有问题,classpath最后加.了吗
helpall 2003-04-14
  • 打赏
  • 举报
回复
javac NetTool.java

java NetTool
chouchou 2003-04-13
  • 打赏
  • 举报
回复
没问题呀,可以执行。是不是你的ClassPath没有设置好?

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧