1 2 Previous Next 23 Replies Latest reply: Jul 14, 2011 3:12 AM by EJP RSS

    Reload .properties

    803772
      Hi,
      Here is the scenario, my properties class holds the value for my variable which the value change everday. How i want to get the value without restarting the server.
      Please help. Thanks.
        • 1. Re: Reload .properties
          EJP
          Properties.load()
          • 2. Re: Reload .properties
            803772
            got error.. Properties cannot be resolved. Please advice. Thanks.
            • 3. Re: Reload .properties
              EJP
              You haven't confided in us exactly how you are accessing these properties in your Java code. So I assumed you were using the java.util.Properties class which is provided for that purpose. Evidently you aren't doing that. So what are you doing exactly?
              • 4. Re: Reload .properties
                803772
                Im getting value form my TradeEngine.properties.
                For an example :
                numOfWorkingDays = 4 , but the value change every week. I need to restart the server to get the latest value.
                How i can get the updated value without restart the server. ?
                I have no idea how to do it. Please advice. Thanks.
                • 5. Re: Reload .properties
                  EJP
                  You are getting values from TradeEngine.properties how?*

                  Your example doesn't answer that question. I can't answer your question until you answer mine.
                  • 6. Re: Reload .properties
                    803772
                    String dayOfWork= System.getProperty( "numOfWorkingDays" );
                    • 7. Re: Reload .properties
                      874671
                      You can make a timer task which runs every day particular time, which reloads the properties-> Properties.load
                      • 8. Re: Reload .properties
                        803772
                        Hi user9121290,
                        Appreciate if you can provide me some sample code. Thanks.
                        • 9. Re: Reload .properties
                          874671
                          http://www.javapractices.com/topic/TopicAction.do?Id=54

                          In the above link you can find how to schedule TimerTask. In the TimerTask run method you need to make a call to Properties.load(Reader). Pls go through the API documentations or sample applications.
                          • 10. Re: Reload .properties
                            EJP
                            String dayOfWork= System.getProperty( "numOfWorkingDays" );
                            That doesn't answer the question either. System.getProperty() doesn't read .properties files. Somewhere in your application you* are doing that. And that is the process that you need to repeat whenever the file changes, or at whatever intervals are appropriate.
                            • 11. Re: Reload .properties
                              796440
                              EJP wrote:
                              String dayOfWork= System.getProperty( "numOfWorkingDays" );
                              That doesn't answer the question either. System.getProperty() doesn't read .properties files. Somewhere in your application you* are doing that. And that is the process that you need to repeat whenever the file changes, or at whatever intervals are appropriate.
                              Even after all these years, I'm still dumbfounded when somebody like Chinna here can't be bothered to read or understand the responses that he asked for. Or, if he doesn't understand them, to ask for clarification in a meaningful way, other than, "Please do my work for me because I'm a lazy twaat."
                              • 12. Re: Reload .properties
                                EJP
                                Me too, but the result of all those years of experience, going on 14 years here in my case, is that posters only read (a) the latest response and (b) only the first sentence of that.

                                If it doesn't consist of a piece of code they can cut and paste immediately into their application, they then repeat the question, either in the same thread or a new one.

                                In the rare cases when they do read on, they make sure to respond to direct questions in the most irrelevant manner possible.

                                It isn't exactly a rational mode of enquiry.

                                But then if they had some idea about that they mostly wouldn't be posting here at all ... and waiting for a response ... and doing God knows what in the meantime ... anything but reading the documentation, or thinking about the problem ...
                                • 13. Re: Reload .properties
                                  Darryl Burke
                                  Cross posted
                                  http://www.java-forums.org/new-java/46392-reload-properties-class.html

                                  db
                                  • 14. Re: Reload .properties
                                    EJP
                                    Great, I vote to lock it.
                                    1 2 Previous Next