Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to make java.net use host file?

843790Aug 31 2006 — edited Sep 4 2006
Hello.

I have an app on one machine (call it local) that tries to connect to another server (call it remote) using java.net, specifically creating a new URL object passing it the host name, port and protocol. I have defined the host name 'remote' in my host file, but we also have another machine with this same name in DNS.

We want to connect to the machine defined in the host file. But when I execute the code and print out the ip address of the host, it's giving me the ip of the machine in DNS.

How can I make it consult the host file first? I thought this was standard behavior. When we do a 'ping' to 'remote' from 'local', it returns the correct ip, the one in our host file. But java.net seems not to use the host file ...

Is this possible?

Thanks,
Bob
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 2 2006
Added on Aug 31 2006
10 comments
2,888 views