On Feb 28, 10:38 am, sublim...@gmail.com wrote:
> Ok here's my problem:
> I have a java program, that I don't have class to.
>
> This java program, once started, sets up a command line for itself;
> Once the command line is there, I have to give it a command to fully
> start, and then i have to send it a password.
>
> At this point it binds some ports and runs along happily.
> The command line stays open in case I want give it status commands, or
> check its config or any other number of admin/health check tasks.
>
> What I want to do, is use either runexec, or exec it as a thread from
> a java program to do the following:
> Start it
> send the second start command to the command line
> send the password command to finish the start
> give the command line back to the user so they can interact with it.
>
> This is on windows btw. In fact on windows I have an intermediate
> sol'n.
> I setup a batch file to do a java class arguments <
> file.with.start.and.password
>
> which will start the program and pipe the commands form the file, but
> then it doesn't let keyboard interaction with the command line since
> its reading stdin from the file
>
> I tried runexec to do what i wanted but I couldn't get the timeing of
> the input/output/error streams to the process correct, ie waiting for
> the programs command prompt to init so i could send the second start/
> password, and I couldn't figure out if i could swap the intput stream
> from a file to the keyboard after it was fully started.
>
> When I load the program as a java class, and start it as a thread I
> can't get access to the streams either. I thought with that setting i
> might be able to do a piped stream to enable me to swap them around
> but that doesn't seem like it can work either.
>
> Thanks
Look at ProcessBuilder
<
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/
ProcessBuilder.html>
It gives you access to the streams.