Setting Environment Variables for NetBeans, Continued

This is a feature introduced in NetBeans 6.7.

Set environment variables for specified life-cycle phases: Open project properties dialog, select action category. Select actions which depend on the variable, click add button to add such an environment variable.

However, this method doesn’t work with Glassfish spawned the IDE. If you want use environment variables in the server spawned by NetBeans IDE, you still have to export the variables in netbeans.conf

Setting Environment Variables for NetBeans

If you use NetBeans IDE to build an application which reads environment variable, you will have to do these settings in your IDE. There is no GUI to set such variables in NetBeans while Eclipse provides you a “Run Configuration Dialog”. So just add the declaration in your netbeans.conf.

It is highly recommended to copy the configuration file to your home directory before you edit it.

cp -r /usr/local/netbeans-6.8/etc ~/.netbeans/6.8/

And append this line:

export YAN_RESOURCE=/home/sun/work/yan-resource

Then restart your IDE, it works. You can test/build/run your application with the environment variable $YAN_RESOURCE inside NetBeans IDE,