How to specify an environment property on the command line?

Question:
How to specify an environment property on the command line?

Code:
public class PropertiesTest {
  public static void main(String[] args) throws Exception {
 
    String str = System.getProperty("myprop");
    System.out.println("myprop=" + str);
 
  }
}

Output:
$ java PropertiesTest
myprop=null

$ java -Dmyprop=abcdefg PropertiesTest
myprop=abcdefg