I use both NetBeans and Eclipse as IDEs for developing Java code. In some cases (notably when the code employs the CPLEX optimization library), I need to set an environment variable at run time (in the case of CPLEX, to point to the license file). Eclipse provides an easy way to do this as part of the run time configuration for the project, but for whatever reason NetBeans lacks this feature (a singularly dopey omission IMHO).
After considerable time spent with Google, it appears that if you need to set environment variables on a project-level basis, the best option in NetBeans involves hacking the build.xml file in ways that I cannot begin to fathom. Fortunately, if the environment variable works globally (across projects), there's a simpler answer. In the NetBeans installation tree there's an etc/ folder containing a configuration file (netbeans.conf). Just add the line export key=value and the problem is solved.