Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add new System Properties in java

Is it possible to add new values to Java System Properties. If there is any how can introduce new keys with there corresponding values in Java System Properties.

like image 341
Nelo Angelo Avatar asked Mar 16 '12 12:03

Nelo Angelo


People also ask

How do I set custom system properties in Java?

Programmatically, a system property can be set using the setProperty method of the System object, and also via the setProperty method of the Properties object that can be obtained from System via getProperties.

Where is Java system Properties file?

properties file located in users->appdata->locallow->sun->java>deployment and also directly putting key=value in runtime parameter in java control panel but not working. Edit: We use jeety server for deployment.


2 Answers

Either System.setProperty or use the -Dname=value flag when you start the JVM

like image 106
dty Avatar answered Sep 25 '22 14:09

dty


Yes:

public static void main(String args[]) {     String key = "a new property";     System.setProperty(key, "a property with a value");     System.out.println(System.getProperty(key)); } 
like image 41
assylias Avatar answered Sep 22 '22 14:09

assylias