system-properties

Jetty - set system property [duplicate]

[亡魂溺海] 提交于 2021-02-17 14:47:05
问题 This question already has answers here : How to portably read configuration data from a servlet (4 answers) Closed 5 years ago . I run webapp on Jetty. The configuration for the app come from file that lives on the same server where Jetty is running. Inside the app I rely on the system property to obtain path to the file so I can parse it. E.g. final String loc = System.getProperty(FACTORY); Now I can start jetty with D switch to provide $FACTORY on the command line but I rather put it in

Maven property overloading

大兔子大兔子 提交于 2020-01-11 05:05:52
问题 I have very simple maven descriptor which defined some properties: <?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <properties> <it.port>8080</it.port> </properties> </project> I can override it.port property with command: $ mvn -Dit.port=8181 verify But following command doesn't work as expected: $ MAVEN_OPTS="-Dit

When to use environment variables vs. system properties?

↘锁芯ラ 提交于 2019-12-31 22:03:44
问题 I wonder which of the following is a preferred approach? We can set things up as APP_HOME=/path/to/file ( export in .profile or something along those lines) and access it as System.getenv("APP_HOME") Or, alternatively using properties as -DAPP_HOME=/path/to/file and access it as System.getProperty("APP_HOME") Now .. either one will make the value available for the application stand point, but is either approach preferred? Why? When? 回答1: If you are using Java 1.3 or 1.4 (and 1.2, IIRC), you

Setting system properties in Groovy

社会主义新天地 提交于 2019-12-23 11:52:14
问题 Please note: Although I mention Swing and MacOS here, this question has nothing to do with either of them: I'm just providing them as a concrete example of what I'm trying to do. I'm trying to set a system property the groovy way. If you are developing a Swing app on a Mac, it is common practice to set the following system property so that your Swing app's menu looks the same as typical Mac apps: System.setProperty("apple.laf.useScreenMenuBar", "true") When I call that inside my main method,

Recursively change system property at runtime in java

随声附和 提交于 2019-12-21 21:25:14
问题 I am having a question and searching for an example for changing system property at runtime in java. In other words , I am having a standalone library which will load System.setProperty("javax.net.ssl.trustStore", trustStorePath) where the value of trustStorePath will change according to condition. If condition changes then I need to change the value of trustStorePath and need to set System Property. But the story is when I set the value for very first time, it stores the value and use it

Change user.home system property

随声附和 提交于 2019-12-17 18:48:11
问题 How do I change the user.home system property from outside my java program, so that it thinks it's a different directory from D:\Documents and Settings\%USERNAME%? Via environment variables, or VM arguments? 回答1: Setting VM argument should work: java -Duser.home=<new_location> <your_program> Here's a test case: public class test { public static void main(String[] args) { System.out.println(System.getProperty("user.home")); } } Tested with java 1.5.0_17 on Win XP and Linux java test /home

What's the difference between a System property and environment variable

微笑、不失礼 提交于 2019-12-17 09:21:07
问题 I am not clear about this. When I run a java App or run an Applet in applet viewer, (in the IDE environment), System.getProperty("java.class.path") gives me the same as System.getenv("CLASSPATH") which is the CLASSPATH defined in my env variable. But when I deploy my applet to webserver and access it from the same computer as a client, I get different results for the two. ( System.getProperty("java.class.path") only points to JRE home and System.getenv("CLASSPATH") returns null). And here is

How to read system property from maven in java

霸气de小男生 提交于 2019-12-11 18:09:04
问题 I am working on a web application which is running on tomcat server. I have different properties files for the different environment, So I want to read my environment variable from pom file in java file and set that environment property when running command mvn clean install . Here is my pom file: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0