Tuesday, November 23, 2010

Netbeans : Providing command line arguments inside Netbeans

I write a lot of command line Netbeans (6.9) Java programs. A lot of them take command line arguments e.g.


java Program Option1 Option2


and you access them from "String[] args".

When you are running inside Netbeans, you need to provide the arguments by:

Right click the project / Properties / Run / Arguments

If you right click the Java file you are testing (the Main class) and select "Run File" the program runs but ignores the configured arguments.

To get around this, you have to right click the project and select "Run".

Enjoy!

No comments: