Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Environment variable not set, from Netbeans

Tags:

c

netbeans

I am calling an external program from my c program in netbeans, where I had to set a environment variable!

I did that by using this command:

export MY_VARIABLE=/exampe/path/

And then I run the program from the command line and it works, but when I start netbeans and run it, he is still complaining that the MY_VARIABLE is not set..

Am I missing something here?? I have netbeans 8.0 and OSX System

like image 440
malajedala Avatar asked Nov 29 '25 18:11

malajedala


1 Answers

CommandLine exports only last for the active session ..
That said, you have to make sure it's set when the program is running.

You can run:

// will set only if $MY_VARIABLE isn't set
system("[[ -n $MY_VARIABLE ]] || export MY_VARIABLE=/example/path");

or

// will set anyways
system("export MY_VARIABLE=/example/path");

to make sure it is set

Alternatively, if that didn't work, you can set the environment variable from within netbeans.

Properties->Actions->Run Project->Set Properties: Add Env.MY_VARIABLE=/example/path

like image 165
Amr Ayman Avatar answered Dec 01 '25 10:12

Amr Ayman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!