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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With