Set the Value of a System Property from the Command Line in Java

Description

The following code shows how to set the Value of a System Property from the Command Line.

Add -D option to the java command when running your program.


java -Dmy.prop="my value" MyApp

Example


/*from  www. j  a va 2  s  .  c  o  m*/




public class Main {
  public static void main(String[] argv) throws Exception {
  
    String prop = System.getProperty("my.prop");
  
  }
}




















Home »
  Java Tutorial »
    Development »




Java Algorithms
Java Clipboard
Java Compiler
Java Desktop
Java Virtual Machine
Java Math
OS
Random
Java Robot
Java RuntimeMXBean
Java Timer
Java UUID
Java Internationalization