Changing The Source Directory in NetBeans

After reorganizing the directory structure on my workstation a bit, NetBeans refused to load the sources for the projects I have configured. The reason for this is probably because I store the NetBeans metadata files separate from the Source directory itself (as I don’t want the NetBeans project files in the repository, etc.).

NetBeans did however not have the option of choosing another source location (changing the existing location) for an existing project. Well, no worries. Luckily the NetBeans project files are in straight forward text format, so we can easily change it there instead! Close NetBeans (so that you don’t accidentally overwrite the new project file) Find the project directory and open “nbproject”. The file “project.properties” is the one we’re after. Close to the top (on line 3 here) you should find:

src.dir=<old path>

Simply change it to:

src.dir=<new path>

while remembering to pay attention to any escape sequences etc along the way (under Windows, \ needs to be escaped, so c:\\Directory\\SubDirectory is the appropriate path).

2 thoughts on “Changing The Source Directory in NetBeans”

Leave a Reply

Your email address will not be published.