Putting Netbeans AppData in the Right Place


If you use Windows Vista/7 and Netbeans, you’ve likely seen a .netbeans and .netbeans-registration folder appear in your user directory. Netbeans is a very nice piece of software, but like many open-source programs, it goes by the mistaken belief that application data always goes in the home folder. This is perfectly normal for Linux, but Windows is not Linux. Windows application settings go in the AppData folder. It is possible to get Netbeans to store its settings in the right place, and it isn’t too difficult.

This guide will show you how to put Netbeans settings in the right place for Windows Vista/7, but you can also use it to put the settings directories anywhere you want on any system. I’ll assume you are using Netbeans 6.9. If not, change the version number where appropriate.

Find netbeans.conf

Open an explorer window and find the directory where Netbeans is installed. The default location is C:\Program Files\Netbeans 6.9 (C:\Program Files (x86)\Netbeans 6.9 for 64 bit systems). Inside it, there should be a folder called etc and inside that, a file called netbeans.conf. Run an instance of your preferred text editor as administrator (you won’t be able to save the file otherwise) and open netbeans.conf in it.

Change netbeans_default_userdir

The second line of netbeans.conf defines the settings directory. Change it to look like this:

# ${HOME} will be replaced by JVM user.home system property

If you move your .netbeans and .netbeans-registration folders to this new location, Netbeans will pick up your settings, but it will still create the same two directories in your user directory and it will ask you to register again. This is because there are actually two options you need to change. The second one is a little harder to find.

Define -J-Duser.home

Line 6 of netbeans.conf defines a bunch of options, each starting with -J. You need to add another option to this line. Before the quote at the end of the line, add this: (replace USERNAME with your username)
[code lang=”text” light=”true”]-J-Duser.home=C:/Users/USERNAME/AppData/Roaming/Netbeans[/code]

Your netbeans.conf file should look something like this now.

# ${HOME} will be replaced by JVM user.home system property
# Options used by NetBeans launcher by default, can be overridden by explicit
# command line switches:
netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Dapple.laf.useScreenMenuBar=true -J-Dsun.java2d.noddraw=true -J-Duser.home=C:/Users/USERNAME/AppData/Roaming/Netbeans"
# Note that a default -Xmx is selected for you automatically.
. . .

And now you’re done! Netbeans should no longer clutter your user directory with its settings.