Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java and SFTP

 
Andres Delrotti
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
#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.
 
Andres Delrotti
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Sheriff
Pie
Posts: 20771
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Bartender
Pie
Posts: 725
29
Android Eclipse IDE Java Linux MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 543
4
Java Netbeans IDE Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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').
 
Andres Delrotti
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
^^

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
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic