aspose file tools*
The moose likes Java in General and the fly likes How to pass parameters to exe, executed using java code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to pass parameters to exe, executed using java code" Watch "How to pass parameters to exe, executed using java code" New topic
Author

How to pass parameters to exe, executed using java code

Rocky Roy
Greenhorn

Joined: Aug 04, 2010
Posts: 8



My target is to run external exe file throught java programm and communicate with it.
i am able to get the out put of exe but faceing problem with blocking calls.. i will explain:

For example

if i want to get out put of c program i.e. test.exe ( it will print hi on console if we run this file directly)

then by using following code




I get out put as
hi

on java console

but if a c program has bloaking call in it
for example let test.c contains a code




now when i run executable file of above program(test.exe) using java code given above it will goes in
infinite waitting state.
i think the reasone is text.exe wait for user to give input but in this case user is a java program who
dont have any idea about that so process goes into infinite waitting condition..


So My question is

>>>>>>>>>>>>> WHAT TO DO ???

i want java program to print " Enter number = "
then user will give number
the number given by user to java program should be passed to
test.exe
and final out put "You entertd =(number given by user) " should be printed on screen





Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
The first thing to do is to cut way down on the number of smilies you use in your posts.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38348
    
  23
Welcome to the Ranch

Lester Burnham has a good point.

Please search this forum and "Beginning Java" because several other people are asking very similar questions just now.
Rocky Roy
Greenhorn

Joined: Aug 04, 2010
Posts: 8
all the post i gone through
are just doing one way communication with process
but what i want to do is to create java wrapper to execute c program exe


for example :

Wneh program will print
Enter The Number :
i will display this message in jave frame.
and ask for input from user and pass the same to c program exe process.

and again get what ever the feedback of program to the java frame;

so it is a kind of 2 way communication with process
by handling
stdin,stdout,stderr and what ever...
Rocky Roy
Greenhorn

Joined: Aug 04, 2010
Posts: 8
Campbell Ritchie wrote:Welcome to the Ranch

Lester Burnham has a good point.

Please search this forum and "Beginning Java" because several other people are asking very similar questions just now.



>>>>>>>>>>>>

all the post i gone through
are just doing one way communication with process
but what i want to do is to create java wrapper to execute c program exe


for example :

Wneh program will print
Enter The Number :
i will display this message in jave frame.
and ask for input from user and pass the same to c program exe process.

and again get what ever the feedback of program to the java frame;

so it is a kind of 2 way communication with process
by handling
stdin,stdout,stderr and what ever...
Rocky Roy
Greenhorn

Joined: Aug 04, 2010
Posts: 8
please help me with above issue

i tried search many time but still no answer found
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

You're Java program needs to read data from p.getInputStream(), then recognize when to send data to p.getOutputStream(). Unless you can tell it what data read requires what data to be sent this is not going to be easy.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rocky Roy
Greenhorn

Joined: Aug 04, 2010
Posts: 8
Yes you r very right...

this is the point where i am blocked in process ...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to pass parameters to exe, executed using java code