0

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

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Marcelo, can you please elaborate your solution suggested
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.