Tuesday, June 17, 2008

Passing properties from command line

We can pass property from command line. The syntax to pass properties from command line is as follows.

java -D<name>=
<value> .....

The getProperty() method in System class is used to get the value of a property by specifying the property name as key.

Sample Java Code

public class Properties {

public static void main(String[] args) {

String name = System.getProperty("name");
System.out.println("name is " name);
String address = System.getProperty("address");
System.out.println("address is " +address);
String age = System.getProperty("age");
System.out.println("age is " +age);
}
}

No comments:

ORM Framework for Kotlin

In Kotlin, ORM (Object-Relational Mapping) libraries provide a convenient way to interact with databases using object-oriented programming p...