• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with InetAddress  RSS feed

 
bhagavatula indu sekhar
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the following program is working well in my home,but it is not working in college environment.

UnknownHostException is being raised.

in my college we will get connected to Internet through a central server.


import java.io.*;
import java.net.*;


public class Inetdemo {

public static void main(String[] args) {
Inetdemo in=new Inetdemo();
in.view();
}
public void view()
{
try
{
InetAddress inet=InetAddress.getByName("www.google.com");
System.out.println(inet.getAddress()+" "+inet.getHostName());
}
catch(UnknownHostException e)
{
System.out.println("HostERROR!");
}
catch(Exception e){
System.out.print("Exception");
}
}
}
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by bhagavatula indu sekhar:

in my college we will get connected to Internet through a central server.


Do you mean a proxy? Then you have to tell Java about it.
Java Networking and Proxies
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!