Java无法从AIX解析DNS地址:UnknownHostException [英] Java cannot resolve DNS address from AIX: UnknownHostException
问题描述
在AIX上,如果我可以从命令行到达我的服务器(使用ping / telnet)
但是如果我尝试使用java,我有UnkownHostException
这是由于Java不能以某种方式使用DNS,但是不知道为什么如果我使用IP地址,它的工作正常。
这是我的测试程序。
code> import java.net。*;
public class Test {
public static void main(String [] args)throws Exception {
String host = args [0];
int port = Integer.parseInt(args [1]);
System.out.println(连接到:+主机+在端口:+端口);
Socket socket = new Socket(host,port);
System.out.println(Connected!);
socket.close();
System.out.println(已关闭!);
}
}
有人知道某种在AIX下配置禁止程序(如java)访问DNS信息?
我(以及系统管理员)已将我的地址添加到/ etc / hosts中,但它也不起作用。
提前感谢
Java版本:
Java TM)2运行环境标准版(构建pap32dev-20080315(SR7))
IBM J9 VM(构建2.3,J2RE 1.5.0 IBM J9 2.3 AIX ppc-32 j9vmap3223-20080315(启用JIT)
设置系统属性
sun.net.spi.nameservice.provider.1 = dns,sun
在Ubuntu上修复了我的这个问题
I'm having this strange error.
On AIX, if I can reach my server from the command line ( using ping / telnet )
But If I try using java I've got UnkownHostException
This is due to Java cannot somehow "use" the DNS but I don't know why. If I use the IP address it works fine.
This is my test program.
import java.net.*;
public class Test {
public static void main( String [] args ) throws Exception {
String host = args[0];
int port = Integer.parseInt( args[1] );
System.out.println("Connecting to: " + host + " at port: " + port );
Socket socket = new Socket( host, port );
System.out.println("Connected!");
socket.close();
System.out.println("Closed!");
}
}
Is anyone aware of some kind of configuration under AIX that forbids programs ( like java ) to access DNS information?
I ( well the sysadm ) have added my address in /etc/hosts but it doesn't work either.
Thanks in advance
Java version:
Java(TM) 2 Runtime Environment, Standard Edition (build pap32dev-20080315 (SR7))
IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 AIX ppc-32 j9vmap3223-20080315 (JIT enabled)
Setting the System property
sun.net.spi.nameservice.provider.1=dns,sun
fixed this problem for me on Ubuntu
这篇关于Java无法从AIX解析DNS地址:UnknownHostException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!