0

Please provide a way to pass variable value defined in build.xml to Java class

2 Answers2

3

Your build process is one thing, your app running is another. You can't pass a build parameter to a class at runtime.

Perhaps a solution to your problem would be to write your parameter found in build.xml to manifest.mf, and then read it from there at runtime.

You can do it like this:

build.xml
<manifest file="MANIFEST.MF">
    <attribute name="MyParameter" value="123"/>
</manifest>

And in your java file, take a look at the answer Reading my own Jar's Manifest.

Community
  • 1
  • 1
Marcelo
  • 4,580
  • 7
  • 29
  • 46
0

You will have to use an XML parser to do that. Read this for more info http://www.java-samples.com/showtutorial.php?tutorialid=152

g2jose
  • 1,367
  • 1
  • 9
  • 11