Praveen Kumar Jayaram wrote:
So am looking for a standard approach supported by Java to use the system property defined using "-D" option, in classpath (using "-cp" option).
Is there any standard approach?
Huh? I have no idea what you mean. Are you saying that if your Java app is invoked as
java -Dabc=xyz -cp pqr MyApp, then you want your app to use "xyz" as its classpath? If that's what you want, it's not possible exactly as stated. You would have to either
A) Have your app use ProcessBuilder or Runtime.exec() to launch another JVM after getting the "abc" system property to pass to that command line.
or
B) Have your app create a ClassLoader that uses the value of the "abc" system property to find its classes, and use that throughout your app.
A better approach, however, would be to just have the "xyz" in the proper place in the command line to start with.