• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pass parameters to exe, executed using java code

 
Rocky Roy
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



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
Posts: 1337
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first thing to do is to cut way down on the number of smilies you use in your posts.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50168
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please help me with above issue

i tried search many time but still no answer found
 
Rob Spoor
Sheriff
Pie
Posts: 20659
64
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rocky Roy
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you r very right...

this is the point where i am blocked in process ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic