How to Set Default Gateway,Ip Address and Subnet mask from Java?
I am looking some way to configure my Ethernet card from Java. Is there any way to change Default Gateway,IP address and subnet mask from Java.
Currently I am using OSHIto get the ip address,Mac address and other Hardware info. I also understand that the only way to set these parameters is Java.lang.Runtime Class and using Hardware specific command to set properties from here
I am looking for a cleaner way to do this for Linux, Windows and Mac. I am basically trying to set all this properties from my own application. Is there a library or wrapper like OSHI to do execute host specific command?
你可以做这样的事情
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);
链接地址: http://www.djcxy.com/p/36478.html