Archive for September, 2012

System.getenv would not work until you restart the IDE (Netbeans)

September 27, 2012 Leave a comment

Today i tried to get the value of a newly created environment variable, I was using Netbeans 7.1 (windows 7), it returned null, however the variable was added. I got to console and executed the program from there, it worked fine. It took me an hour to find out the problem. The problem was that while netbeans is running and you add a new Environment Variable and then try to get it by using

System.getnv() or System.getenv(String name)

it will return null until you restart your Netbeans. Probably there might be some issue that values are not updated for the Netbeans process, so you have to restart your Netbeans (i’m not sure about Eclipse and others :/). After that you’ll get the value of the newly added environment variable. A quick tip if you are facing the same, restart your netbeans..! 🙂

Categories: Java