2

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).

1

2 Answers 2

15

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"));
Sign up to request clarification or add additional context in comments.

Comments

4

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

1 Comment

Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.