sparkyspider
sparkyspider

Reputation: 13529

Tomcat: How do I set up a Java system property in Netbeans?

How do I, from Netbeans, for use with Tomcat, set up an environment variable that I can read using System.getProperty(...);

We have a source controlled project - and we're constantly making changes to confirurations that we "would" like to share (don't want to use svn:ignore). We're trying to set up one simple parameter, an environment variable to the config properties of our application. For example: mark.properties or john.properties. If the system can't find the environment variable, then it defaults to server.properties (for the live system).

Upvotes: 2

Views: 9349

Answers (2)

sparkyspider
sparkyspider

Reputation: 13529

1. Go to the Tomcat Properties Platform Settings

In Netbeans, click the "Services" tag. Under "Servers", you'll see "Tomcat 7.0". Right click "Tomcat 7.0" and select "Properties". Then select the "Platform" tab.

2. Under VM Options, add -Dvariable=value

Leave the D in place, and replace the variable with whatever variable name you'd like to set and value whatever value you'd like to set the variable to.

3. Read out the property from your code.

System.out.println("The value is " + System.getProperty("variable"));

Upvotes: 15

kbdjockey
kbdjockey

Reputation: 897

The answer is just in the NetBeans FAQ here:
http://wiki.netbeans.org/FaqSysPropsDuringRun

Upvotes: 4

Related Questions