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

后端 未结 2 1468
心在旅途
心在旅途 2020-12-11 10:34

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

We have a sou

相关标签:
2条回答
  • 2020-12-11 10:54

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

    0 讨论(0)
  • 2020-12-11 10:57

    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"));
    
    0 讨论(0)
提交回复
热议问题