I have searched for a way to change this (unwanted) behavior. I set command line arguments in Project->Properties->Run->Parameters and run my program in NetBeans IDE. Arguments gets passed to my program just fine, but they also turn up when I run the .jar from a .bat-file or .sh-script after it is compiled. So my customer ends up having my test arguments activated if I forget to remove the settings from project settings before distributing my .jar. I would have expected this info to be removed from the .jar. At least after compiling without debug information. Is there a way to remove the arguments from my distribution without removing them from my project settings? Anyone else having the same problem?
You could add a configuration (Project->Properties->Configurations->Add), select the created configuration under "Project->Properties->Run" and specify the arguments only for this configuration. But this way is NetBeans specific. If you are using Maven you should use profiles. Add something like this into your pom.xml:
<project>
...
<profiles>
<profile>
<id>test</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!--your command line arguments-->
<exec.args>hello world</exec.args>
</properties>
</profile>
</profiles>
...
</project>
You still would need to remember to deactivate your development profile before shipping but like this you can separate the configuration between development and production system in a clean way. (Especially if later on there should be other configuration values which should differ, like logging level, different paths and so on).