0

I need to define environment variables for my project since I will eventually want to deploy it to Heroku, or any other PaaS. What I am having trouble with is run the application from the NetBeans IDE with my environment variables.

Where can I enter them so I can test them? I use environment variables for MongoDB URI, different API keys, etc.

Edit: I am using OSX 10.10.2 with NetBeans 7.4.

I tried looking at this discussion but my version of NetBeans lacks the Set Properties: Add in the Run dialog.

andreicek
  • 53
  • 2
  • 10
  • I did find [this Stack Overflow question](http://stackoverflow.com/questions/8577249/how-do-i-set-up-a-java-environment-variable-in-netbeans) but I am not sure these are environment variables. – andreicek Feb 27 '15 at 18:11
  • I think those are indeed environment variables. – childofsoong Feb 27 '15 at 18:13
  • Nope, unfortunately using the -Dvariable=value System.getenv() won't get that variable. – andreicek Feb 27 '15 at 18:20
  • That's odd. Have you tried running it on command line? My guess is that you have a small error that's throwing it off. – childofsoong Feb 27 '15 at 18:25
  • Tried running with `java -jar "app.jar" -Dtesting=1` and I still get null. But if I use System.getProperty() it works. **Edit:** This is because `System.getProperty()` gets a Java property, but `System.getenv()` gets an OS environment variable. – andreicek Feb 27 '15 at 18:30
  • Ah, I see! Sorry, I had environment variables and Java properties mixed together in my head (I need more caffeine!). Check out https://stackoverflow.com/questions/11823233/how-to-set-environment-variable-in-netbeans - I think that's what you want. – childofsoong Feb 27 '15 at 18:33
  • Yeah, I found that link too. But I have no Set Properties: Add in the Run dialog. – andreicek Feb 27 '15 at 18:36
  • In that case, I would recommend you post what version of Netbeans you are using and what OS, as that may affect where things are located. Hopefully someone who knows Netbeans better can tell you where it's found. – childofsoong Feb 27 '15 at 18:39
  • Edited the question with OS version and as well NetBeans version. Thanks for trying! – andreicek Feb 27 '15 at 18:41

1 Answers1

0

You should look in the Actions dialog, not in Run. There you select 'Run project' and then click the Add button.

Marcel Korpel
  • 21,536
  • 6
  • 60
  • 80