aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes how to pass input to java program using ant ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "how to pass input to java program using ant ?" Watch "how to pass input to java program using ant ?" New topic
Author

how to pass input to java program using ant ?

naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 692

i have successfully invoked my java console application using ant but i m not sure how i can give input to my java console application i have develop this code



The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

So, what specific problem are you having? I see code that looks like it will read all the output of the ant it invokes and print that out to the console, and that does not send any input to that program via the console.

So, the first question is, how do you wish to provide this input? If the and demo expects it as a command line arg, then you just need to modify what you exec() appropriately. If the and demo expects is to come from the console via its System.in, then, just as you're currently proxying its System.out to your console, you need to proxy from your console to its System.in.

This article may help.
naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 692

Jeff Verdegan wrote:So, what specific problem are you having? I see code that looks like it will read all the output of the ant it invokes and print that out to the console, and that does not send any input to that program via the console.

So, the first question is, how do you wish to provide this input? If the and demo expects it as a command line arg, then you just need to modify what you exec() appropriately. If the and demo expects is to come from the console via its System.in, then, just as you're currently proxying its System.out to your console, you need to proxy from your console to its System.in.

This article may help.

from System.in I will be able to get the input from the netbeans console but how exactly i can transfer that to my program which i am invoking using ant.
my problem is the program reads the ant output , i guess till here its fine for you , but while writing the output to the console in the while loop it gets into infinite loop because it is expecting input from the user, but i m not able to come out of the while loop so that i can read the netbeans console and send it to my console app using printwriter, does you have any solution for that
and by the way i have already read the above said article from javaworld
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

naved momin wrote:
from System.in I will be able to get the input from the netbeans console but how exactly i can transfer that to my program which i am invoking using ant.


1) Read the article I linked.

2) You can only do it if that ant task is set up to accept input from the console in the first place. If it's not written to accept it, you can't force it. It will just not read any bytes you send to it.

my problem is the program reads the ant output , i guess till here its fine for you , but while writing the output to the console in the while loop it gets into infinite loop because it is expecting input from the user, but i m not able to come out of the while loop so that i can read the netbeans console


Read the article. It shows you how to set up separate threads for reading and writing.

and by the way i have already read the above said article from javaworld


Then you already have your answer, and I don't understand why you're positing here. I also don't understand why, having read that article, you failed to follow the model it provided.
 
 
subject: how to pass input to java program using ant ?