How to write binary file in remote machine using j-interop? - java

I am using J-interop and java to interact with window remote machine, I am able to connect to the remote window machine using j-interop but do not know how to write binary files to window remote machine. If any one have sample code to do that it will be highly appreciated.

If you can use another Java library then I would suggest you to look at JCIFS. http://jcifs.samba.org/
I have success to use this library to perform file operations from a Linux node to Windows node (XP, 2003 Server, 7 and 2008 Server).
Good luck

Related

How to detect when a new SATA drive is inserted using Java under Linux?

I am currently working on a project where I need to bulk import data into a Hadoop cluster. The data that needs to be imported into Hadoop resides on SATA disks. The data that needs to be imported are Encase forensics disks image (E01). I created an application that extract files from these images and import those files into Hadoop, this works fine but I need to start the process by hand.
I want to automate the process by hot-swapping the SATA drives and automatically start the extract process. I wrote my program in Java and it needs to be that way due to some external libraries I use to analyse the images. I searched the internet for a solution where Java is used to detect newly inserted drives but all I found where libraries that can detect usb drive or used udev rules to kick start the a process (I could use that but prefer a Java solution)
Does anyone know if something like what I have described exists? Or does anyone can point me into the right direction? It would be much appreciated!
Almost forgot...I use ubuntu 12.04 Server Edition as my operating system.
udisks is a D-Bus API that provides information (including notifications) on media insertion and removal, and you could subscribe to the notifications using dbus-java.
Alternatively, you could have your Java application listen on a localhost socket and write a udev rule that sent the appropriate event information over the socket.

Remote file transfer between windows system using Java

How to do remote file transfer between windows system using Java? In more detail, these windows systems are in same domain. I want Java API, which can transfer files (ASCII and Binary) between windows system by using assigned username, password, domain name and source and destination file location.
Use Sockets to connect (previous configuration by IP) to a SocketServer and transfer the files.
I've never done this, but I'd say you'll need to use the native Windows API to achieve this.
You could do it with JNI and C#. C# has File.Copy (see example here) that makes use of native CopyFile function.
Alternatively, take a look at this question on SO.
Hope this gives you some leads.

Alternatives to Jibble Web Server with php support?

Well at school we are not allowed to run .exe's (YES WE have windows... omg why, also you can't save DLL files) so when I needed an FTP server I just download a Java FTP Server named FTP-GO. We can run jar files, but only by double clicking on them, so we cannot provide any parameters. What I want now is a web server in a jar file which also supports PHP scripts, the disk limit I have is 100mb, of which I am using 25mb (but I can run jars from an USB stick). so if there is any equivalent to http://www.jibble.org/jibblewebserver.php which also supports PHP, which one would you recommend?
Maybe Quercus or Der Herberlin Bremsserver.

query on file transfer using java socket programming

I need to move few files in a directory to another directroy in another machine. The source and destination directory names are known in advance. These directories will be in different Operating System(i.e. the source can be Linux and Destination can be in Windows).
To solve this, i wrote a Socket program in Java that successfully copies files from source directory to a destination directory(Tested in Windows OS). But this application needs program running in both the host and remote machine. So, my question is :
1) Is there any way to transfer files(in the ways described above) using Java Socket program without having a program running in the remote machine?
2) Whether file transfer using Java socket program, bypass firewal. In other words, if a firewall is present in the remote machine will that stop the transfer process?
3) Any alternative approach to transfer files(in the ways described above) using Java where only the host or remote need to run.?
Thanks in advance,
nks
1) You always need a program running on both machines. However, a way to get around this problem is to use a program already running on one of these machines.
e.g. If you make the directory a Windows share (assuming this is already running) you can mount this share on the Linux box (using smbfs), you can then copy files using cp This means you don't need Java on either end, but you need A program and A service (but it can be an existing one)
2) There isn't a way to by-pass a firewall unless your network is seriously mis-configured. This is the whole point of having one.
3) Once you mount either the Windows box on Linux, or the Linux files (using Samba) on Windows youc an copy files easily, even using Java. ;)

Moving a file from a windows Java application to a linux box

I'm currently doing a project that has to be run on a windows machine. The application creates a CSV file and saves it to the windows filesystem. I would like a way to transfer this file to a machine running linux into a directory selected by the user.
I am not asking for code (although if it helps then feel free :P ) but asking more for what protocols to use (ftp etc) and wether I need to take anything into account such as permissions in Linux as I am fairly in experienced with programming for linux file systems.
Thanks in advance :)
Can the windows machine see the linux filesystem? Is there a samba server running on the linux machine? If so, you can simply copy it from one filesystem to the other.
If not, you can try SCP or SFTP but you need to have the keys setup. Another way is to use Runtime.exec to copy the file using a windows specific command utility.
If all else fails, run a java process on the linux server and connect to it using sockets. Your windows client can write the file to the socket and it can be written out by the linux server.
I would try using SSH as SCP is a fairly standard and convenient way to transfer files securely. In Java you can use jssh amoungst other libraries.
If you don't want to do it programatically, I'd suggest using Rsync. It should be available for most *nix distros and you've got a Windows version called DeltaCopy that implements the same protocol.

Categories

Resources