<p>I am refering to the <a href="https://stackoverflow.com/questions/252893/how-do-you-change-the-classpath-within-java#252905">question</a> on changing the classpath programmatically.</p>

<p>I read and found out that there is some function under <strong>System</strong> class as getproperties where we can retrieve the properties and then also can set it using setProperties().</p>

<p>The answers however I got was that It Wont work. I have not tried this myself, however, i am taking the call.</p>

<p>Just to clarify, then why these  setProperty() and getProperty() methods are there if they cannot alter it at run time. Or is this specific to the classpath property only ?</p>

<p>I will appreciate if someone can present a scenario where they are really helpful?</p>

System.setProperty can be used to set some security or protocol handler at the beginning of a program. Like:
```
```
/*
Add the URL handler to the handler property. This informs 
IBMJSSE what URL handler to use to handle the safkeyring 
support. In this case IBMJCE.
*/
System.setProperty("java.protocol.handler.pkgs", "com.ibm.crypto.provider");
```
```
or for
using SSL
:
```
```
System.setProperty("javax.net.ssl.keyStore", context.getRealPath(KEYSTORE));
System.setProperty("javax.net.ssl.keyStorePassword", "password");
System.setProperty("javax.net.ssl.trustStore", context.getRealPath(TRUSTSTORE));
System.setProperty("javax.net.debug", "ssl");
HttpClient httpClient = new HttpClient();
GetMethod httpGet = new GetMethod("https://something.com");
httpClient.executeMethod(httpGet);
return new String(httpGet.getResponseBody());
```
```
But beware, because it
changes the environment at runtime for
ALL
applications running in the same jvm
.
If for example one application needs to run with saxon and the other with xalan and both make use of System.setProperty to set the transformerFactory, then you will run into trouble
As said in
Monitored System.setProperty
article,
System.setProperty() can be an evil call.
It is 100% thread-hostile
It contains super-global variables
It is extremely difficult to debug when these variables mysteriously change at runtime
Regarding the classpath property, as
I said in a previous question
, it can not be easily changed as runtime.
In particular, java System property java.class.path is used to build a linked link when the JRE is instantiated, then
is not re-read
. Therefore, changes you make to the property don't really do anything to the existing virtual machine.