user705414
user705414

Reputation: 21200

Argument passing using -D

How to handle the variable passing using -D, like -Dcontext=web in Java code?

Upvotes: 5

Views: 4125

Answers (1)

WhiteFang34
WhiteFang34

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

Related Questions