File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes Problem in connecting to FTP server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Problem in connecting to FTP server" Watch "Problem in connecting to FTP server" New topic

Problem in connecting to FTP server

Manupriya Sinha

Joined: Aug 19, 2008
Posts: 4

I am using apache commons library for connecting to FTP server. Please find below the code -

Now my problem is - I do not get any exception but still ftp.getReplyString() returns '530 Login incorrect.'. Can you please help me with this.

We are using port 22 on the ftp server. Can that be the reason for this error?

I modified my code and included port as well while connecting, as folllows -
ftp.connect(addr, 22);

but now I am getting an exception -
Server Reply: SSH-1.99-OpenSSH_3.6.1p2
at com.novus.file.ftp.JakartaWrapperTest.main(

Is it to do something with Active FTP or Passive FTP?


JCE - Please Use Code Tags
[ August 19, 2008: Message edited by: Joe Ess ]

Regards,<br />Manupriya<br /> <br />SCJP 1.4 - 98%<br />SCWCD 1.4 - 94%
Joe Ess

Joined: Oct 29, 2001
Posts: 9168

Originally posted by Manupriya Sinha:

Server Reply: SSH-1.99-OpenSSH_3.6.1p2

This reply leads me to believe that you are connecting to an SSH service, not FTP. Port 22 is usually bound to an SSH server. Port 21 is typical for an FTP server.
Have you tried connecting with an FTP client?
Are you supposed to be using SFTP (FTP over SSH)?

[How To Ask Questions On JavaRanch]
Manupriya Sinha

Joined: Aug 19, 2008
Posts: 4
Thanks a lot Joe !!

I will try code for sftp now.
I agree. Here's the link:
subject: Problem in connecting to FTP server
It's not a secret anymore!