how to upload a Folder from Windows to Linux machine using Java - java

how to upload a Folder from Windows to Linux machine using Java. Windows machine is the client machine. I am establishing the connection to Linux machine on windows machine using putty, java code will be running on linux machine. This is a servlet based project.

I'd suggest trying FTP, since your working from Linux to Windows.
Windows is a little cranky about these things so it might take some setting up it get it to work.
Check out How to retrieve a file from a server via SFTP? for some suggestions.
If you can, I'd reverse the process, copy the folder from Windows to Linux, Linux just seems to be easier to get setup to handle this kind of thing...IMHO

You can use FTP, SSH or Telnet. FTP and SSH are preferable.
If you choose SSH I suggest you to use JSch. For FTP you can use VFS from Jakarta.

Related

How to run an application on headless remote Linux server and see the UI on my local Windows machine

I have a swing application which takes some input files, manipulates them, and displays it in its UI. Currently I have a remote headless Linux machine where the data files are (changes everyday). So is there a way in which I can run that application on a remote Linux machine and see its UI on my local Windows machine? I heard it's possible using JNLP stuff. I am very new to this, any suggestion on this is highly appreciated.
Thanks.
You need to install on windows machine X server software and redirect the display of your software to your X server. Example X server software are Exceed, MobaXterm, etc. After you start the X server you should login in to the linux machine and execute
export DISPLAY=<your IP address>:0.0
and then run your software

How to execute a bat file on a different machine and fetch the output in Java

I need to execute a Windows .bat file on a different machine. I know :
the IP address of the remote machine, and
the executable file location.
How do I execute that particular file and how can I get its output?
Both the machines run Windows.
I already saw these links:
http://docs.oracle.com/javase/1.5.0/docs/guide/rmi/hello/hello-world.html
http://www.onezerozeroone.eu/html/rmi_howto.html
But I am still not very clear on how to start?
You can't do this just using Java and RMI.
For obvious reasons, there isn't a way of running code on a remote machine unless that machine is set up to allow that sort of access. Otherwise, anyone could run anything on your machine at any time!
If it's a .bat file that you want to run, then you should look at setting up something like an ssh server on the other machine. That way, your machine will be able to connect to it via ssh (using a Java library if you like), execute the .bat file, and capture the output.
But if it doesn't need to be a .bat file, and you just want some of your own code to be triggered on the remote machine, you could write a (Java) application to run on the remote machine and listen on a particular port for messages instructing it on what to calculate, and then return the results.
That is pretty much the standard pattern for all remote services, including web servers.

Writing files to windows machine from Broker (Unix)

I have a requirement to create/append file on windows machine from WebSphere Message Broker Toolkit v 7.0 (Unix). Unix user does not have permissions to access the windows machine. I wanted to write a Java code which can create or append to a file with other credentials which has access to windows machine (not FTP, it's a shared drive in the same network but a different group).
I found some solutions which the client don't want to use whatever constraints.
Creating a NFS mount point and write to that mount point location.
Use SAMBA framework.
Can anyone suggest something other than this ?
Thanks in advance.
Run a WebSphere MQ Managed File Transfer agent on the Windows host. Then the broker can simply send files to the agent which will write them to the local filesystem on the Windows host. This capability is built into modern versions of MQ.

How can I run a batch script from java on a remote windows machine

I have a machine that runs batch scripts over ssh on windows machine using open ssh and cygwin (copssh)
I'm looking to change this mechanism since this tool requires configuration where many mistakes can be made.
I will also need to collect the results of the script
Any ideas on how it can be done?
Thanks
You can use RMI and on the remote side just use Runtime.getRuntime().exec

Copying and executing local files to a remote server with windows and linux using java

What I'm attempting to do is copy a number of files from one host machine to a remote server using java and after the copy is made, I'll execute those files that I transferred. The host machine may have some dependencies like requiring putty or some other program but I'm hoping that there might be a solution that doesn't require anything installed on the remote side. And on top of that, this needs to be OS independent, though different methods can be used for different communications. I'll have access to the IP address and admin control (root username and password).
What I've had so far was that for Windows to Windows, I can mount the remote windows drive and access the files that way. In Windows to Linux, I can use putty or a similar program to ssh into the remote box. I'll also ssh from Linux to Linux and obviously I won't need putty. I can't figure out what to do for a Linux to Windows instance that won't require me setting up some ssh method on the remote end. Any ideas? Any way (or library) to perform both the copy and/or execute methods that won't even be OS specific?
A simple solution is to use what Windows already offers: rdesktop or the more comfortable Terminal Server Client if you are on a Gnome machine.
To get the files to the Windows box, you can set up Samba Client on your Linux machine and mount the Windows file share, copy your files there, connect via rdesktop and then execute them.

Categories