Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I pass an environment variable to a Netbeans Makefile on Ubuntu?

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.

like image 319
John Carter Avatar asked Oct 14 '22 11:10

John Carter


1 Answers

Edit:

This answer is possibly not valid for Unity-based flavours of Ubuntu.


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 (No Mercy? :) 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.

like image 108
John Carter Avatar answered Oct 16 '22 23:10

John Carter