从java为Windows XP中的网络接口设置ip地址 [英] Set ip adress for network interface in Windows XP from java

查看:351
本文介绍了从java为Windows XP中的网络接口设置ip地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从我们的Java APP在Windows XP机器上设置IP地址。由于我不知道如何从java中完全设置它,我想使用 netsh 设置它。 Howerver因为有多个接口我需要获得特殊的长名称的网络连接。

Nethsh命令将如下所示:

I need to set IP adress on Windows XP machine from our Java APP. As I do not know any way how to set it purely from java I would like to use netsh to set it. Howerver as there are more than one interfaces I need to obtain special "long name" of network connection.
Nethsh command will look like this:

 netsh interface ip set address name="Local Area Connection" source=dhcp

我尝试使用

NetworkInterface

类来获取它,但没有成功。对于Windows XP上的网络名称,它返回的名称如eth0:)

class to obtain it, but without success. For network name on Windows xp it return names like "eth0" :)

我正在解析命令ipconfig的输出,但不仅仅是有问题的,它也不适用于各种XP语言的突变。

I am currently parsing output of command "ipconfig", but not only it is problematic, it also do not scale with various XP language mutations.

推荐答案

使用Java修改Windows注册表。这些链接可以帮助您。

Modify windows registry with Java. These links should help you.

http://www.windowsreference.com/networking/dhcp-static-ip-settings-in-windows-registry

使用Java读取/写入Windows注册表

这篇关于从java为Windows XP中的网络接口设置ip地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆