I have a java file where a variable taken value at run time.I search for a service using web service discovery and keep its url in a variable. Now I need to pass this value
I don't consider this as an Apache Maven specific issue, but a general Java issue (Maven probably made you aware of it). During build-time you have no idea what the url should be. Depending on the type of application you have several options:
In you use a framework like Spring there are easy ways to inject one the options above.