Announcement Announcement Module
No announcement yet.
Is there a built in way to set JVM properties for a Spring applicaiton context? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is there a built in way to set JVM properties for a Spring applicaiton context?

    I have found that for a particular application context it is desireable to set a JVM property. Rather than modify all of the present and future start up scripts that may make use of this application context I would prefer to update the JVM property as a part of the application context. While it would be very simple to create a class with an init method which would set the JVM property and then add a bean definition for that class to the context, I was wondering if Spring already had a built in solution for setting JVM properties.

  • #2
    I might be wrong but I didn't think JVM properties could be modified at run time.

    System properties can, for sure, but not JVM (like -Xms -Xmx etc.) ones...(I think).

    What exactly are you trying to do/set?


    • #3
      The property I would like to change is 'sun.rmi.dgc.server.gcInterval' I have been setting it using the usual -D. Which I guess would mean that it is just a normal property used by java's rmi package. Thanks for pointing this out.
      Does spring provide a built in way for modifying such properties?


      • #4
        Not that I know of, but why not simply call System.setProperty..... I suppose for robustness you could always abstract it behind a facade with a get/setGcInterval...but other than that, no, I don't see where Spring would get involved?


        • #5
          Double check as well when that property is referenced....if it is referenced on startup then you will probably need to refresh the applicationContext to reload the RMI related beans (and cause them to re-evaluate that system property) whenever you change the property.
          If it is read every time then no worries....