views:

655

answers:

1

I'm using Netbeans on Linux (Ubuntu 9.04) to build a C project.

How do I pass in an environment variable so that's it's visible to the Makefile?

If I do a normal export MYVAR="xyz" and then run make from the command line this works fine of course.

But Netbeans doesn't seems to use the .bashrc environment, so if I click "build" in Netbeans, the make fails.

Interestingly, the problem doesn't seem to occur on MacOSX - I've added the variable to ~/.MacOSX/environment.plist, and that value is visible to Netbeans.

I found this post which suggested modifying ~/netbeans-6.8/etc/netbeans.conf. I've tried this, by adding -J-DMYVAR=xyz to the end of netbeans_default_options, ie:

netbeans_default_options="-J-client -J-Xverify:none -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Dapple.laf.useScreenMenuBar=true -J-Dsun.java2d.noddraw=true -J-DMYVAR=xyz"

But this didn't seem to work.

Any ideas?

+2  A: 

The issue is actually nothing to do with NetBeans - it's related to the Ubuntu (ie Gnome) Launcher.

As this blog post explains, you need to add variables to the rather obscure ~/.gnomerc file in order for them to be passed to applications started with Launcher!

So just edit ~/.gnomerc and add the variables as you would to ~/.bashrc, eg:

export MYVAR="xyz"

and logout/login.

therefromhere