SFTP to FTP bridge - java

I would like to connect with an SFTP client to an FTP server using java. I know the two technologies have nothing to do with each-other. What I'm trying to accomplish is to connect to an FTP server via the internet with out using two ports or changing the server configuration.
Is there any SFTP->FTP bridge in java it would be great. If not, how can I accomplish that ?
I would like to incorporate this in an exciting java server so hence, java based solutions are preferred. If there is some standalone software which you can control via code than it should support windows and *nix.
(Since SFTP is just the means here, a similar WebDav solution will also work)

You could go with trial and error. Try this out see if it works.
How to retrieve a file from a server via SFTP?

Related

Remotely accesing file from java

I am working at an application in java from windows. I have to connect to a server. I only know the ip: 172.... and port. I want to obtain the last modified date for a file on that server. I have tried some methods but it doesn't work. I read a lot about http, ftp, sftp but this things are not clear for me, and i could not understand how to obtain the date. Please help me!
I have tried with urlConnection, with ftp etc..
On windows the file sharing protocol is CIFS.
You have a java Open source library which implement this protocol : jcifs

SFTP to retrieve files from Windows server to Linux server using java

I am working on file download functionality.All my files are in Windows server,is there any Library in java which can be used to do SFTP to transfer files from remote windows server to Linux server where my Java app is running?
use JScape's secure FTP library from this link
given you have access to both peers, you can use SSLServerSocketFactory/SSLSocket for the connection on both ends.
Edit:
some basic example on how to establish connection and read/write data: http://stilius.net/java/java_ssl.php
wow, hope you are satisfied with our software :)
thank you,

How can i upload file in remote machine(LAN) using java

How can i upload file in remote machine(LAN) using java program.I want to connect remote machine in LAN and upload file from my local machine to remote machine.So please tell me how can i do this.
I suggest you use JSch. You'll be able to connect easily to a remote machine and it allows you to execute file transfer using sftp for example.
It's hard to find a real documentation for JSch, but the various examples they give on their site are really complete and in general sufficient to help one succeeding in his task.
You probably want an HTTP client library for Java, to issue an HTTP POST request. (I assume the remote machine has some web server to upload the file).
Google gives several suggestions, like Hc.Apache

How can I access to a file exists on remote machine?

I want to access to a file (read) that exist on a remote machine from my code JAVA,what I need to do that?
just the IP of the machine and the location of the file or I need somthing else?
Thank you
There are some choices:
Via a 'mapped' directory using SMB/Samba to the remote machine and you can then access the file using the normal File class.
Via a Web Server where read access is easier (if you require write access then you are looking at something like WebDAV). This requires the use of the HTTP protocol in your code.
Via FTP or SFTP network protocols to access the file. This obviously requires the use of (S)FTP classes to access the file.
The first option is easiest from a coding point-of-view.
If both the Java code and the remote file are on Linux machines, you can also choose NFS.
As always you need to start a server which serves the file - you need nfsd to share the directory containing that file on the remote machine.
On the machine where your Java code will run, mount the shared nfs
Here is a brief introduction of using nfs on Ubuntu.
If you prefer FTP/HTTP, you will be interested in Apache commons vfs library, which supports many protocols including FTP, SFTP, HTTP, etc.
First of all, you need a service on the remote machine that serves files. Once a file-serving service exists, you communicate with the service using its protocol.
Assuming the client-server model, you have several choices on the remote (server) side. First of all, you can design your own protocol, write a server, deploy it on the remote machine and write a client (in Java) which will talk with the server using the designed protocol. However, there many off-the-shelf solutions (protocols + servers + Java client libraries) that might be used. Three protocols which come to mind right now: TFTP, FTP and SMB.
If your aim is simplicity, I recommend TFTP: there are free TFTP servers for UNIX, Windows and Mac OS X, and there is Apache Commons Net Java library on the client side.

Java upload files to remote linux server WITHOUT ftp or scp

I am trying to write a program in java to upload some files from my local environment to a remote server. I cannot use FTP because there is no FTP server installed on that instance. Also port 22 is closed so I can't use scp either.
Is there any other way to approach this?
Thanks in advance guys!
You need something on the serverside, a program, which is waiting for your file. You can't just send something there.
An open port is always a program running, waiting for a connect.
So a couple of possible protocols are rsync and WebDav. But at the end of the day I recommend one of two options. Get ssh installed, or use rsync.
Talk to the unix admin and work something out.
Even linux servers sometimes use smb/cifs (the Microsoft technique to share files and folders) to publish data. The samba team provides a 100% Java library to access those: http://jcifs.samba.org/

Categories

Resources