如果是2000/XP,可以使用下面的代码来设置本地IP.//Execute.java public class Execute { private static void setIP(String newip) throws Exception { Runtime.getRuntime().exec("netsh interface ip set addr \"本地连接\" static "+newip+" 255.255.255.0 192.168.32.1 1"); }
public static void main(String[] args) throws Exception { System.out.println("Begin to set the local ip address\nPlease wait..."); System.out.println("\nAfter setting the ip, the program will auto exit..."); setIP("192.168.32.100"); System.out.println("Set ip successful!"); } }
public class Execute
{
private static void setIP(String newip) throws Exception
{
Runtime.getRuntime().exec("netsh interface ip set addr \"本地连接\" static "+newip+" 255.255.255.0 192.168.32.1 1");
}
public static void main(String[] args) throws Exception
{
System.out.println("Begin to set the local ip address\nPlease wait...");
System.out.println("\nAfter setting the ip, the program will auto exit...");
setIP("192.168.32.100");
System.out.println("Set ip successful!");
}
}
确实试验过,没有问题啊?
------------------------------------
体验速度,体验CSDN新版论坛助手:http://community.csdn.net/Expert/TopicView.asp?id=3108679