使用JAVA更改计算机IP地址 [英] Change Computer IP address using JAVA
本文介绍了使用JAVA更改计算机IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用java更改计算机IP地址...我试过这个但是这不起作用...
I need to change computer IP address using java... I have tried this one but this doesnot work...
String str1="192.168.0.201";
String str2="255.255.255.0";
String[] command1 = { "netsh", "interface", "ip", "set", "address",
"name=", "Local Area Connection" ,"source=static", "addr=",str1,
"mask=", str2};
Process pp = java.lang.Runtime.getRuntime().exec(command1);
推荐答案
您(可能)需要正确连接这些 key = value
参数 - 如所写的,它们将被视为单独的参数,即
You (probably) need to correctly concatenate those key=value
arguments - as written they'll be treated as separate arguments, i.e.
{..., "addr1=" + str1, "mask=" + str2 };
这篇关于使用JAVA更改计算机IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文