Error During Ftp Transfer Java.net.unknownhostexception
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up java.net.UnknownHostException not able to connect to ftp up vote 2 down vote favorite 1 I have ftp port as: ftp://173.201.0.1/ I am trying to connect it through following: String Ftp_Path = "ftp://173.201.0.1/"; public List
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join http://stackoverflow.com/questions/21985467/java-net-unknownhostexception-not-able-to-connect-to-ftp them; it only takes a minute: Sign up How to give FTP address in java? up vote 1 down vote favorite 1 I have written the code which downloads the file from FTP server. Since I have my FTP server locally and I want to access like "ftp://localhost/alfresco". It was alfresco's FTP. I have the following Code public class http://stackoverflow.com/questions/4562536/how-to-give-ftp-address-in-java FtpTransfer { public static final void main(String[] args) { FTPClient ftp = new FTPClient(); FileOutputStream br = null; try { ftp.connect("ftp://localhost/alfresco"); ftp.login("admin", "admin"); String file = "KPUB//Admin//TMM//Pickup//TMM_TO_ARTESIA_06152010220246.xml"; br = new FileOutputStream("file"); ftp.retrieveFile("/"+file, br); System.out.println("Downloaded..."); } catch(IOException exception) { System.out.println("Error : "+exception); } } } The following exception occurs. Error : java.net.UnknownHostException: ftp://localhost/alfresco Please let me know how should I give the FTP Host Address? java ftp apache-commons share|improve this question edited Dec 30 '10 at 12:21 Vladimir Ivanov 31.5k145894 asked Dec 30 '10 at 12:19 i2ijeya 3,784134364 another note, when ftping to other domains like mysite.com, you can either pass in ftp.mysite.com or mysite.com to the connect method. but mysite.com will not work. –Kenny Cason Dec 30 '10 at 13:09 Once retrieved, where my downloaded file resides. –i2ijeya Dec 30 '10 at 13:11 It will be in the directory where you ran your program from –Kenny Cason Dec 30 '10 at 13:26 also many files need to be transferred as binary, so to put FTP in
for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Ask a https://www.experts-exchange.com/questions/27510041/Reason-for-getting-UnKnown-host-exception-FTP-in-a-java-program.html Question Ask for Help Receive Real-Time Help Create a Freelance https://coderanch.com/t/517792/sockets/java/FTP-site-works-unable-connect Project Hire for a Full Time Job Ways to Get Help Expand Search Submit Close Search Login Join Today Products BackProducts Gigs Live Careers Vendor Services Groups Website Testing Store Headlines Experts Exchange > Questions > Reason for getting UnKnown error during host exception FTP in a java program Want to Advertise Here? Solved Reason for getting UnKnown host exception FTP in a java program Posted on 2011-12-27 Linux Networking 1 Verified Solution 4 Comments 937 Views Last Modified: 2012-05-12 While trying to connect FTP through a java program, we got the below error during ftp 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.
This Site Careers Other all forums Forum: Sockets and Internet Protocols FTP site works but I'm unable to connect from Java program. I get java.net.UnknownHostException Karthic Raghupathi Greenhorn Posts: 9 I like... posted 5 years ago Greetings folks. I have this weird problem. In the project I'm working on now, I need to upload a file to a FTP site. I have written many programs that do this before and they have worked just fine. But this particular site is giving me trouble. When I try to upload the file from the program, I get this to be specific: java.net.UnknownHostException: ftp://site.com However when I try to connect to the same site from within a browser (Chrome, IE) or from windows explorer, I'm able to find the site and login just fine. So I'm stumped now. If I could not connect from windows, then I can assume it is a FTP server issue. This happens to me only from the Java program. And I also know that my code works as I have used in numerous occasions before. Here is the code I use: public void uploadFile(String fileName) throws Exception { FileTransferClient ftpClient = null; try { ftpClient = new FileTransferClient(); ftpClient.setRemoteHost(gv.ftpHost); ftpClient.setRemotePort(21); ftpClient.setUserName(gv.ftpUserName); ftpClient.setPassword(gv.ftpPassword); ftpClient.getAdvancedFTPSettings().setConnectMode(FTPConnectMode.PASV); ftpClient.connect(); ftpClient.uploadFile(gv.irp + fileName, fileName, WriteMode.OVERWRITE); } catch (Exception e) { throw new Exception("Error occured in uploadFile()\n" + e); } finally { if (ftpClient != null) { if (ftpClient.isConnected()) { ftpClient.disconnect(); } ftpClient = null; } } } I use the edtFTPj library. My environment is Eclipse Helios (32 bit) on Java 1.6 (32 bit) running from a Windows 7 64 bit machine. Any insight on resolving this will be greatly appreciated. Thanks for your time. Karthic Raghupathi Greenhorn Posts: 9 I like... posted 5 years ago Never mind people. I just figured this out. The parameter I was passing to the code was ftp://site.com which is a URL. I must have passed just site.com. That did the trick. Thanks for your times. Post Reply Bookmark Topic Watch