Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't System.setProperty() change the classpath at runtime?

Tags:

People also ask

What does system setProperty do in Java?

The System. setProperty() method forms the basis for test case automation on any browser. Naturally, QAs must understand how to use this fundamental method for all automation purposes in Selenium.

How do I set system properties in environment variables?

To get a specific system property, we can use the System. getProperty() method while to fetch a specific environment variable, call the System. getenv() method. System properties can be added at runtime using System.

What is the value returned by system getProperty user home?

The getProperty method returns a string containing the value of the property. If the property does not exist, this version of getProperty returns null.


I am refering to the question on changing the classpath programmatically.

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

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

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 ?

I will appreciate if someone can present a scenario where they are really helpful?