How to detect if a Java System property has changed?

java, jmx, listener, properties

Solution

You can replace the system Properties with your own custom subclass.

MyProperties newProps = new MyProperties(System.getProperties());
System.setProperties(newProps);

Then, just write a subclass of Properties which hooks the relevant methods.

Problem

I would like to know when a System property is changed. I have an application, in an application server, that somehow is changing a system property (`System.setProperty()` I think). I was taking a look and I have found different approaches: - JPDA? - Observer & Observable? - Property change listener? - JMX? Any suggestions? Thanks in advance.

Original source

Related problems