System.getProperty driving me nuts

Is it just me or is there a problem with IDEA reading properties during run/debug? I swear I've done this 100 times and while it works fine from the command line it doesn't appear to work in the IDE. I've tried my 10 CE and my new Ultimate 13 installs with the same results.

public class PropertyTester {
    public static void main(String[] args) {
        String property = System.getProperty("property1");
        System.out.println("property = " + property);
        String property2 = System.getProperty("property2");
        System.out.println("property2 = " + property2);
        String property3 = System.getProperty("property3");
        System.out.println("property3 = " + property3);
    }
}

Program parameters: -Dmy-property1=abc -Dmy-property2= -Dmy-property3=ghi

What IDEA prints:
property1 = null
property2 = null
property3 = null

What command line prints when executing the jar:

property1 = abc

property2 =

property3 = ghi

What in the world am I missing? Maybe I've been staring at it too long.

3 comments
Comment actions Permalink

1. there's property1 in code and my-property1 in parameters, the same for all props
2. you need to pass "-Dmy-property1=abc -Dmy-property2= -Dmy-property3=ghi" not as program arguments, but as VM options. See Run | Edit Configurations...

0
Comment actions Permalink

Put it into "VM options", because these are not program arguments, but VM arguments. Also property names are wrong, try these:

-Dproperty1=abc -Dproperty2=foo -Dproperty3=ghi


...too late. :8}

1
Comment actions Permalink

Good grief. The property name was an oversight but where I was putting them was just plain silly. I knew I was staring at it too long. I didn't even realize it and I was so focused I missed the forest for the trees.

Thanks guys. :)

0

Please sign in to leave a comment.