How to handle the variable passing using -D
, like -Dcontext=web
in Java code?
To pass one or more arguments to a procedure In the calling statement, follow the procedure name with parentheses. Inside the parentheses, put an argument list. Include an argument for each required parameter the procedure defines, and separate the arguments with commas.
The two most prevalent modes of passing arguments to methods are “passing-by-value” and “passing-by-reference”.
Passing arguments to function is a very important aspect of C++ programming. Arguments refer to values that can be passed to a function. Furthermore, this passing of arguments takes place for the purpose of being used as input information.
You pass an argument by reference by specifying the ByRef keyword for the corresponding parameter in the procedure definition. When you use this passing mechanism, Visual Basic gives the procedure a direct reference to the underlying programming element in the calling code.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With