File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes How to call windows exe file placed in windows machine from unix machine Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to call windows exe file placed in windows machine from unix machine" Watch "How to call windows exe file placed in windows machine from unix machine" New topic
Author

How to call windows exe file placed in windows machine from unix machine

vardhan reddy
Ranch Hand

Joined: Oct 28, 2011
Posts: 42
Hi All,

I want to call exe file which is place in windows environment from Unix operatign system, unix and windows server are place in same organization (different countries).

Can any one tell how can I call exe file.

Nitin Surana
Ranch Hand

Joined: Jan 21, 2011
Posts: 129

Method 1:
Use java RMI to execute a remote method on the target machine, which in turn executes a program in that machine using Runtime class.

Method 2:
You can use java sockets to transmit a message to the target machine and the program on the target machine on receiving this message executes a program using Runtime class.

vardhan reddy
Ranch Hand

Joined: Oct 28, 2011
Posts: 42
Thanks Nitin,

Can you please explain in details, I have no idea how to communicate between unix and windows.
If possible please provide any documents, it will be very helpful.

If I call below code what will happen, does it execute windows exe file?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19781
    
  20

You can't call Windows programs directly from a Unix machine. Unix uses a completely different mechanism for executables. You will need to setup a client-server pair, with the client on the Unix machine and the server on the Windows machine. The client sends commands to the server which will then use Runtime.exec or ProcessBuilder to execute these commands. That's what Nitin meant.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2516
    
  10

. You can youse Ant's 'telnet' task to log on to the remote unix and execute the commland there.
. Some FTP servers support the 'site exec' command. If your company's unix machine runs such an ftp server, that would be an option.


OCUP UML fundamental and ITIL foundation
youtube channel
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19781
    
  20

Be warned that Telnet is a very insecure protocol. You should not allow any computer outside your local network to use it, and even within the local network you should limit access as much as possible.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2516
    
  10

Rob Spoor wrote:Be warned that Telnet is a very insecure protocol. You should not allow any computer outside your local network to use it, and even within the local network you should limit access as much as possible.

Yes it is (same for FTP). These protocols send everything readable over the network. It is always a good idea to let the company's security team validate the approach.
The good thing is that the vulnerabilities are known . Starting to build an own client/server application/protocol from scratch might introduce security holes still unknown to mankind.

Next step could be to step over to SSH , SSH tunneling
Maybe the WAN route between the two countries is already secured and encrypted?

vardhan reddy
Ranch Hand

Joined: Oct 28, 2011
Posts: 42
Thanks Rob/Jan,

We are calling with in our network only and I got one option to call windows services using FreeTDS.
and we are checking to mount windows folder and use it in unix machine(not calling exe/ control files).
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19781
    
  20

Just because you can mount the Windows shares and see the .exe files doesn't mean you can run them.
vardhan reddy
Ranch Hand

Joined: Oct 28, 2011
Posts: 42
Ok, got your point.
We are planning to mount folders which contains excel files (these files will be used by exe). we will place exe file in unix environment itself.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19781
    
  20

That won't work, unless you can use Wine to open the exe files. That probably means that you need to install the application properly in Wine.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8403
    
  23

vardhan reddy wrote:We are planning to mount folders which contains excel files (these files will be used by exe). we will place exe file in unix environment itself.

As has already been pointed out, Unix CANNOT execute .exe files, so it doesn't matter where you "put" it. On the other hand, OpenOffice CAN open most Excel files (and edit them; although what it replaces them with may not be the latest type).

Winston

BTW: I would suggest using Samba to connect your Windows shares. It is very robust and I believe can be tunnelled through SSH (although I've never tried it).


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to call windows exe file placed in windows machine from unix machine