Reason for getting UnKnown host exception FTP in a java program

While trying to connect FTP through a java program, we got the below exception.

java.net.UnknownHostException: HOSTNAME      
at java.net.PlainSocketImpl.connect(Unknown Source)
      at java.net.SocksSocketImpl.connect(Unknown Source)
      at java.net.Socket.connect(Unknown Source)
      at java.net.Socket.connect(Unknown Source)
      at java.net.Socket.<init>(Unknown Source)
      at java.net.Socket.<init>(Unknown Source)
      at com.sprint.ftp.FtpClient.openServer(FtpClient.java:426)
      at com.sprint.ftp.FtpClient.<init>(FtpClient.java:586)
      at com.sprint.ftp.FtpClient.main(FtpClient.java:867)
java.net.UnknownHostException: HOSTNAME

How to rectify this?
joe_suganthAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rahul GadeSr. ArchitectCommented:

The exception is clearly telling you that the Java.net library was not able to resolve the hostname specified for connection.
Can you check following command on command prompt:
C:\>ftp <your HOSTNAME>

I am confident that this will show you the error message "Unknown host <HOSTNAME>".

So For verification ensure that you can ping the hostname using HOSTNAME. If by IP it is working but not by name, means you have dns resolution problem. In that case either contact your network admin for correcting the dns record or edit the etc\hosts file for local resolution.

-Rahul Gade
0
joe_suganthAuthor Commented:
Thanks. Getting the Unknown host exception.
0
Rahul GadeSr. ArchitectCommented:
If this has solved your problem, you can close the question by allocating points.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
joe_suganthAuthor Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Networking

From novice to tech pro — start learning today.