Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Argument passing using -D

Tags:

java

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

like image 665
user705414 Avatar asked Apr 21 '11 22:04

user705414


People also ask

How do you pass an argument?

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.

What are the 2 ways of passing an argument to a method?

The two most prevalent modes of passing arguments to methods are “passing-by-value” and “passing-by-reference”.

What is passing argument function?

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.

How are arguments passed using the ByRef method?

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.


1 Answers

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.

like image 164
WhiteFang34 Avatar answered Sep 28 '22 03:09

WhiteFang34