re-setting system property in java
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   lakshmi_rajagopal
Posted On:   Tuesday, February 12, 2008 12:14 AM

I am retrieving emails from a mail box using pop3 over SSL. For that purpose I am setting a truststore variable as a system property. System.clearProperty("javax.net.ssl.trustStore"); Properties p = new Properties(System.getProperties()); p.put("javax.net.ssl.trustStore", "C:\cacerts"); System.setProperties(p); Everything works fine. But lets say that, in my current executing thread, this parameter needs to be altered runtime, to, Say a file in a non-existing folder, System.clearProperty("javax.net.ssl.trustStore"); Properties p = new Properties(System.getProperties()); p.put("   More>>

I am retrieving emails from a mail box using pop3 over SSL. For that
purpose I am setting a truststore variable as a system property.



System.clearProperty("javax.net.ssl.trustStore");
Properties p = new Properties(System.getProperties());
p.put("javax.net.ssl.trustStore", "C:\cacerts");
System.setProperties(p);




Everything works fine.


But lets say that, in my current executing thread, this parameter
needs to be altered runtime, to, Say a file in a non-existing folder,



System.clearProperty("javax.net.ssl.trustStore");
Properties p = new Properties(System.getProperties());
p.put("javax.net.ssl.trustStore", "C:\certificates\cacerts");
System.setProperties(p);




And, also that I delete the C:\cacerts file to make sure the new path
is picked up...


The program fails !


I see that this property is being set only once on program initiation. I have to restart the program for any modification to take place.

Any subsequent modification is not being considered.


Is this how this was designed to work or am i missing something?    <<Less

Re: re-setting system property in java

Posted By:   Robert_Lybarger  
Posted On:   Tuesday, February 12, 2008 08:49 AM

Do you know for sure that the javamail API consults that system property every time it needs it, or maybe does it only look the value up the first time, configure itself, and then go on with life? In the latter case (which I suspect is likely) you might have to force javamail to reinitialize somehow. (No, don't ask me how.)
About | Sitemap | Contact