Please provide a way to pass variable value defined in build.xml to Java class
Asked
Active
Viewed 1,713 times
2 Answers
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.
-
Thanks Marcelo, can you please elaborate your solution suggested – user1201896 Feb 14 '12 at 12:22
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