Opening Netbeans PHP Projects from the Windows 7 Command Line

So here is a fabulously irritating bug in the NetBeans CLI.

The basic syntax for opening a NetBeans project from the CLI looks like this:

C:\Program Files\NetBeans 7.2.1\bin>netbeans --open <project path>

And for project paths that do not contain spaces this works as expected. However, if the path to your project has a space then NetBeans goes completely off the rails. For example, if the path to the NetBeans project folder is C:\projects\test project\nbproject then the usual convention in the Windows command line is:

C:\Program Files\NetBeans 7.2.1\bin>netbeans --open "c:\projects\test project\"

Here is where NetBeans breaks down. When you press enter you’ll get an error that reads:

c:\projects\test project" does not exist, or is not a plain file

The clue is in the error (and it’s not the message!) If you look at how the message presents the path you entered you’ll see that it omits the opening quote, strips the trailing back-slash, and keeps the trailing quote. Interesting? NetBeans seems to think that you’re looking for a file with the name test project" so, of course, it’ll fail.

The way to get around this is simply to omit the trailing quote like so:

C:\Program Files\NetBeans 7.2.1\bin>netbeans --open "C:\projects\test project\

This time, when you press enter the project should open in the NetBeans IDE as expected.