Reputation: 21200
How to handle the variable passing using -D
, like -Dcontext=web
in Java code?
Upvotes: 5
Views: 4125
Reputation: 72049
You can reference the variables you passed on the command line with -D
like this:
String context = System.getProperty("context");
So if you passed -Dcontext=web
then the context
above will be web
. Note that you'll get back a null
if it's not set.
Upvotes: 15