呵呵,大斑竹睡觉了,偶来回答2吧
import java.net.*;
class Getip{
public static void main(String args[]) {
try{
String s=InetAddress.getLocalHost().getHostAddress();
System.out.println(s);
}
catch(Exception e){}
}
}
import java.net.*;
class Getip{
public static void main(String args[]) {
try{
String s=InetAddress.getLocalHost().getHostAddress();
System.out.println(s);
}
catch(Exception e){}
}
}
所以返回的就是127.0.0.1,把这个IP改为你的主机名或者你自
己已经定义的地址就OK了。