Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Environment Variable in Netbeans?

I am running maven based Spring project in netbeans . I am using an environment variable in my project configurations file to Open specific file based on that variable value . I am able to set it In Eclipse but do not know how to set in Netbeans . Can any one help me?

like image 589
Rohit Kumar Avatar asked Aug 06 '12 06:08

Rohit Kumar


People also ask

How do I change environment variables in NetBeans?

I could not find that Properties->Actions setting, using NetBeans 7.4. I did not explicitly need an environment variable--just some value I could set outside my application. So, instead, I was able to make a change in the "project. properties" file under the nbproject folder of the main application.

How do you set environment variables?

On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings. On the Advanced tab, click Environment Variables. Click New to create a new environment variable.

Can I set an environment variable in Java?

Right-click the Computer icon on your desktop and select Properties. Click Advanced system settings. Click Environment variables.


3 Answers

System.getEnv("FOO") == "FOOVALUE"

netbeans 6.7+ -

Right click Project

  • ->Properties ->Actions ->Run project ->Set Properties: Add

Env.FOO=FOOVALUE

Note: You can apply the same technique on other configurations and other actions like Debug project

like image 194
sureshnath Avatar answered Oct 09 '22 07:10

sureshnath


I could not find that Properties->Actions setting, using NetBeans 7.4. I did not explicitly need an environment variable--just some value I could set outside my application. So, instead, I was able to make a change in the "project.properties" file under the nbproject folder of the main application.

Within project.properties is a "run.args.extra" setting. Any command line argument you wish to pass along must have its 'name' preceded by '-J'. Here is an example.

run.args.extra=-J-DFOO=FOOVALUE

Note that this is NOT an environment variable. Rather, it is a System.getProperty("FOO") accessible value. Of special note: this is also the place to change how much memory your applications allocate, using Xmx/Xms.

like image 3
Javaneer Avatar answered Oct 09 '22 07:10

Javaneer


On macOS:

In $HOME/.bashrc add alias:

alias netbeans='/Applications/NetBeans/NetBeans\ X.Y.app/Contents/MacOS/netbeans &'

In Terminal:

> netbeans

This will start IDE with user environment variables.

As result environment variables (such as $PATH) available inside NetBeans IDE and tools (such as Ruby debugger).

like image 2
Vlad Avatar answered Oct 09 '22 06:10

Vlad