tags:

views:

645

answers:

3

I have a java program to run and it will print out some messages on the console. When I put the program as an Ant java task, I can't see my output on the console. What should I do?

I should add that I run Ant from Eclipse. The console output does not appear in Eclipse console.

+1  A: 

Ant's java task does not block the standard output of a Java application unless you've configured the output attribute. Can you show what's in your build file? I suspect it's either you wrote the build file wrongly or executed Ant wrongly. Please explain how you tried running your application and whether or not your application prints output to console if run via java on the command line.

aberrant80
This is the build file I used. <target name="deploy"> <echo message="Deploying EAR"/> <copy todir="${deployDir}/${ant.project.name}"> <fileset dir="EarContent"> <include name="**" /> </fileset> </copy> <java classname="weblogic.Deployer" append="true"> <classpath> <pathelement location="C:\bea\weblogic92\server\lib\weblogic.jar" /> </classpath> <arg line="-adminurl t3://localhost:7001 -username weblogic -password weblogic -redeploy -name ${ant.project.name}" /> </java> </target>
Actually I can see the output when I run Ant in command prompt. But the output does not show up when it is run in Eclipse
So it's an Eclipse issue then? When you say "run in Eclipse", are you executing the Ant target in Eclipse or are you just running the app from Eclipse? Depending on how you created your project, Eclipse may not necessarily use your build file. Also, if you *are* executing the Ant via Eclipse, do you see the echo message in your Eclipse's console view?
aberrant80
+2  A: 

you need to specify the 'output' attribute. This will redirect your error and output streams to the file specified as the value of this attribute.

Ryan Fernandes
+1  A: 

Maybe you used spawn="true" ?

Peter Thomas
(You mean fork="true"? agree)
Sean Owen
nope, I used to think so too - but spawn is different, look it up.
Peter Thomas