• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Parameters in Java task

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,
The java class that I wan't to run (with java task) requires a commandline parameter : a single String character.
I know that in the build.xml I can specify attributes...but It's not possible to let the user choose...
How do I let the user insert a command line parameter???
Thanks a lot!!!

actual target
<target name="initiator" depends="compile"
description="execute app.initiator,requires config parameter">
<java classname="app.Initiator" fork="true" classpath="classes"/>
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You didn't actually say that you want the user to run Ant and have Ant run a java app, but your sample makes it look that way. You can define environment variables going to Ant in the same way that you can for any Java application, using the -Dname=value command-line construct. To make it prettier (and safer), wrap the Ant command line with a shell script/batch command file.

To get the command value to the actual java app, just define a param stanza on the Ant <java> command where the value would be substituted in the usual way:



Please check your ant manual on how to pass in parameters. I'm working from my so-called memory. But I hope you get the idea.
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I usually use the -Dname=value style, but also you could take a look at the Input task that prompts the user for a value.
 
reply
    Bookmark Topic Watch Topic
  • New Topic