FaqPortableWorkingEnvironments

How can I set up the NetBeans working environment to be portable? (e.g. on a USB drive)

If you use NetBeans in the office and at home, you might be considering to install NetBeans on an external portable USB drive so that you can take it with you.

The answer is similar to FaqNetworkDrives: Running an IDE from a USB drive is likely too slow to be usable in daily life.

If you do try it:

Make certain you have the same JDK installed (in the same paths) on the machines where you use the USB drive - or copy the JDK on the drive too. The same applies to web servers / version control systems / runtimes, whatever is applicable.

Check whether you have a global netbeans.conf file: If yes, make certain it is identical to the one in your userdir to prevent unexpected behaviour in either environment.

In your netbeans installation directory, open /etc/netbeans.conf in a text editor.

Change netbeans_default_userdir="${HOME}/.netbeans/7.1" to something like

netbeans_default_userdir="X:/.netbeans/7.1"

assuming X is your USB stick's drive name.

Change the path to the JDK from #netbeans_jdkhome="/path/to/jdk" to e.g.

netbeans_jdkhome="X:/jdk"

Make sure to remove the hash sign to uncomment.

If it's running too slow:

Make certain that as much as possible is on the local hard drive. Start with the JDK and the userdir (FaqAlternateUserdir). In NetBeans 7.1, use the --cachedir option to keep disposable caches on a local disk.

Conclusion:

It's probably easier and more efficient to install the IDE on both sides, and then to use a version control system to sync the configurations.

Batch file

Here is a batch file I wrote to modify the conf file to have the right drive letter (your USB drive letter might be different from one computer to the next...)
Just put this batch file somewhere on your USB drive and run it when you wish to launch netbeans.
(In this case, my netbeans install is located in X:\Apps\netbeans\ where X is the USB drive letter)