5

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

user705414
  • 20,472
  • 39
  • 112
  • 155

1 Answers1

15

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.

WhiteFang34
  • 70,765
  • 18
  • 106
  • 111