for just educational reasons I want to access a remote file from java. To be more specific I want to upload somewhere a file at a remote pc and then make a program in java where I open it and read its content.Is dropbox a good option? Can this be achieved programmaticaly ? My main question is is there any free server or something like this where I can upload the file?
FTP (File Transfer Protocol) might be the simplest solution.
One of many FTP APIs in Java: Apache Commons-Net FTPClient
It is very difficult to code an FTP in Java, i would suggest FTPing it using FileZilla. You will need to have an open Server in the remote PC (configured to FTP, port 21/22) and from there you can enter the remote PC's IP address and open port into FileZilla (after the server is configured). From there you can just drag and drop the file. Let me know if this helps.
Related
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
There are some posts regarding how to read from/write to a file in a remote system. However, I haven't found one useful to my purposes and I hope you can help me out.
So far, I have a java program that can connect to a server using sockets. The remote system (server) is not in the LAN which I think makes it more complicated to access files in that computer. The purpose of my "networking program" is to download files that are in the remote server and I can achieve this by copying bytes of the file once I have reached it, but I don't know how to "navigate" through the directories of the server. The only thing I've done so far is to connect to it.
The remote server runs on Linux. I'm trying to find out how to do this and I came across with JSch. I have not read too much about it but I would like to ask you if this is possible with JSch or what is the solution you would use.
JSch can surely work.
Refer this: File download
I am trying to develop a desktop based application which will have a browse button. Once a file is selected by "Open File" dialog. The file should be sent to server(target) machine.
I am unsure of how this can be achieved in java. After searching through internet i found out that. This may be achieved in different ways. Some of them
Use FTP commands.
Socket Programming.
Third party library.
I do not want to use option 1 i.e., FTP because of security. Kindly guide on how this can be achieved ?
If you would like to use FTP, but it does not fit your needs concerning security, you could switch to Secure FTP (sFTP).
A library offering SFTP file transfer for Java is JSch. Example code for an sFTP transfer and even for a secure copy (scp) is available on the JSch webpage.
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
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/