aspose file tools*
The moose likes I/O and Streams and the fly likes Is there any api in java to connect to windows using java from unix machine Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Is there any api in java to connect to windows using java from unix machine" Watch "Is there any api in java to connect to windows using java from unix machine" New topic
Author

Is there any api in java to connect to windows using java from unix machine

Nevin kumar
Ranch Hand

Joined: Mar 15, 2008
Posts: 93
Dear Ranchers,

From the java application which is running on a unix box, need to connect to windows machine and need to do some file operations.


Any help highly appreciated.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41525
    
  53
What, exactly, does "connect" mean - by which means? Maybe FTP or SFTP would be sufficient?


Ping & DNS - my free Android networking tools app
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Or if both systems are connected by a Windows network, then jCIFS might suit your requirements.
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
Samba allows a Linux box to connect to a windows box so that you can see the Windows file system on a Linux box. Does your version of UNIX support Samba? If you can install Samba, then you can use the regular Java file support. I'll bet you will have more trouble with your IT department than you have with developing your application :)
Nevin kumar
Ranch Hand

Joined: Mar 15, 2008
Posts: 93
@Ulf,

When I say connect I mean should be able to access windows from unix machine using a java program.Sometime back I used a ssh client (SFTP connection) for connecting from one mac book to other but I forgot the api .May you suggest any open source and free java api which will full fill my requirement.

@Paul

I need to check whether both the systems are connected in windows Network.



Guys, Thank you very much for your time.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

The most important question still remains, what do you want to do? Execute commands? Read and write files? Something else?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Nevin kumar
Ranch Hand

Joined: Mar 15, 2008
Posts: 93
Dear Rob,

I need to access a particular folder and check how many files are present and get their names and check the file size of each file not zero.some type of file operations.


Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

Then use Samba (or Windows file sharing), either with File (you may need to mount the share first) or using jCIFS.
Nevin kumar
Ranch Hand

Joined: Mar 15, 2008
Posts: 93
I had used an open source ssh client api in java.I was successfully able to connect to linux box from windows machine,but when I tried connecting to windows from unix box.It says connection refused.I had no idea what is the problem ?I had given hostName, userId and password.Any suggestions highly appreciated.


java.net.ConnectException: Connection refused


Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
Have you opened your Windows box appropriately to the network? (File sharing, firewalls, etc).
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

To use SSH you'll need to run an SSH server, and there aren't many SSH servers available for Windows. More importantly, they are never ever installed by default, you'll have to do that yourself. But why not follow the advice you've been given at least twice and use JCIFS in combination with a file share on the Windows machine?
 
Consider Paul's rocket mass heater.
 
subject: Is there any api in java to connect to windows using java from unix machine