aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Java and SFTP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Java and SFTP" Watch "Java and SFTP" New topic
Author

Java and SFTP

Andres Delrotti
Ranch Hand

Joined: Aug 11, 2005
Posts: 137

We need to create an executable program which would send and receive files from the server of the client. The client is already preparing to purchase an SFTP facility of this.

My question is:

1. Can a java program connect to existing SFTP facilities (e.g. RSIT)
2. Is there still a need to have an SFTP facility or is there an existing or new library in java which can do this? if yes, is this a better solution than #1?
3. If #2 is recommended, is jftp still the recommended API for this?


Thanks,.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41884
    
  63
#1 Yes, and the standard Java SFTP library is JSch (on top of which jftp is apparenlty built).

#2 - I'm not sure what you're asking. If you need SFTP -because that's what your client uses- how does something help? Or are you asking how to implement secure file transfer for a greenfield implementation where SFTP isn't set from the start?

#3 - jftp seems to be a GUI client; if you need programmatic SFTP access, then JSch is probably the way to go.


Ping & DNS - my free Android networking tools app
Andres Delrotti
Ranch Hand

Joined: Aug 11, 2005
Posts: 137

Thanks for the input Ulf.

For #2:

What I mean is, can the java api that can do sftp work on its own? or is it dependent on some sort of installation of an SFTP facility in the server ? If yes, that would save our client money because they won't be needing to purchase the SFTP facility to be stored on their server, let the API do all the work.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

I'm not sure if this is your question... but using an SFTP client does imply you're connecting to an SFTP server somewhere.
Andres Delrotti
Ranch Hand

Joined: Aug 11, 2005
Posts: 137

Sorry guys, I got confused with my own question myself haha. Lets start all over.

Ok java connecting to SFTP? check! (Jsch).

My questions are:

1. Would the logic to connect to the sftp server depend on the brand of the SFTP facility ? (e.g. RSIT)
2. Can this handle real time? or batch transfer is advised? both in send and receive
Ron McLeod
Ranch Hand

Joined: Feb 12, 2013
Posts: 314
    
    5

Andres Delrotti wrote:Would the logic to connect to the sftp server depend on the brand of the SFTP facility ? (e.g. RSIT)

SFTP is intended to be interoperable. If you are wondering about a particular implementation such as Attachmate’s RSIT, would you need to try it to be sure, but it would be pretty safe to assume it will work.
Andres Delrotti
Ranch Hand

Joined: Aug 11, 2005
Posts: 137
We're also exploring 3rd party options like THIS

Has anyone tried using these? I'm just worried about using Jsch if it would perform well in a real time file transfer requirement.

Bascially, the setup we want is this.

(Two way file transfer)

Server1-outbound folder ---> Server2-inbound folder
Server2-outbound folder ----> Server 1-inbound folder

Basically file transfer is initiated when a file is dropped off at an outbound folder from either server.

Is this possible in java APIs such as jsch? or third party tools like those in the link I posted is better suited for this?


Dieter Quickfend
Bartender

Joined: Aug 06, 2010
Posts: 543
    
    4

I've developed functionality using Jsch just like this. It's perfectly possible, but you need the right info from the server, you will need to contact systems admin to do all the necessary work (proxy, firewall, port) and give you the right information (which proxy to use, which user, password, etc.), and it's quite possible that you'll need to add some extra properties depending on the SFTP server (for example 'StrictHostKeyChecking').

Oracle Certified Professional: Java SE 6 Programmer && Oracle Certified Expert: (JEE 6 Web Component Developer && JEE 6 EJB Developer)
Andres Delrotti
Ranch Hand

Joined: Aug 11, 2005
Posts: 137
^^

Can jsch do that without polling? i mean can it "listen" if files are dropped off at a certain folder so that it can receive or send it?

i have googled some jsch codes and seen some but not sure if reading or sending files can be automatically triggered
Richard Tookey
Ranch Hand

Joined: Aug 27, 2012
Posts: 1059
    
  10

Andres Delrotti wrote:^^

Can jsch do that without polling? i mean can it "listen" if files are dropped off at a certain folder so that it can receive or send it?

i have googled some jsch codes and seen some but not sure if reading or sending files can be automatically triggered


You are asking too much of SSH and therefore jsch. SSH is a well defined protocol (there are something like 5 applicable RFCs which Google will find) for securely communicating between a client and a server. In it's minimal form SSH does not even have file transfer but SSH does have a standard way of adding functionality and most SSH clients and servers support the SCP and SFTP file transfer protocol extensions. Presumably you need transfer files from the server to the client as soon as they become available on the server. One could do this with jsch or any of the standard Java SSH libraries but you would need to poll the server since there is nothing build into the SSH protocol to allow ans SSH client to be notified of server side file system changes. I do foresee a problem with polling in that it could be difficult to know when a file is actually available as a whole and not currently being written.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java and SFTP