4

I'm trying to get command line input into a running java program that I started with ant. However, nothing of what I type in the terminal is redirected to System.in of the java process. Is this normal? I'm using Windows 7 and Ant 1.8.2.

The part of the ant script in question goes like this:

<target name="run-client" depends="compile" description="Run client.">
    <java classname="client.Client" fork="true" classpathref="project.classpath">
        <arg value="localhost"/>
        ... other args
    </java>
</target>
Hinton
  • 2,320
  • 4
  • 26
  • 32

1 Answers1

3

Did you try simply using the input or inputstring from the java task?

http://ant.apache.org/manual/Tasks/java.html

Since it's only the command line you are interested in.

In other case I don't think one is able to interact with a running application.

FailedDev
  • 26,680
  • 9
  • 53
  • 73
  • So is there really no way to redirect stdin from ant to the java process? This is so annoying. I thought this limitation affected just the thing. – Hinton Oct 08 '11 at 13:47
  • @Hinton Why would you want to do this with ant? – FailedDev Oct 08 '11 at 13:57
  • Yeah I know ant is supposed to be a build tool, but I also use it basically as a "start script" tool - so when I hit "ant run-client", the program should start, and the program expects user input. This idea is not completely mad, cause what's the tag for after all? – Hinton Oct 08 '11 at 13:59
  • Ant is supposed to be a tool which helps you with automated builds. Pausing the build and expecting interaction with the user contradicts with the whole automation concept. So the java task is to run a java app with or without some command line arguments, as is the exec, apply tasks too :) – FailedDev Oct 08 '11 at 14:02