Title: How to invoke a java-method which name is set in a .properties file
Tags: java
Question: I would like to make an indirect call to a java method, which name is specified in a .properties file.
How can I do that ?
Comment: look at this link good example for .properties file http://stackoverflow.com/questions/1318347/how-to-use-java-property-files

Comment: Lets be clear here.  You want to get the name of the method you are going to call from the properties file.  This way any method might be invoked depending on how the properties file is configured.  Right?

Comment: You could use [reflection](https://docs.oracle.com/javase/tutorial/reflect/).

Comment: Do you know the name of the **class** on which you want to call this **method** ?


Here is another answer: Object object = // .....
try(is = propertiesInputStream()) {
Properties p = new Properties();
p.load(is);
Method m = org.springframework.util.ReflectionUtils.findMethod(object.getClass(), p.get("method"));
Object result = org.springframework.util.ReflectionUtils.invokeMethod(m, object);
Comment for this answer: I believe, you don´t need Spring for this, the JDK provides you with an API to do reflection and invoke methods (even if they are private). Let me look for it...
Comment for this answer: See [this answer.](http://stackoverflow.com/a/160976/3046834)
Comment for this answer: `spring-core 4.1.5.RELEASE`, and other versions
Comment for this answer: I agree, you don't need Spring. Spring is just a convenience.
Comment for this answer: `org.springframework.util.ReflectionUtils.findMethod`? What's the dependency on that one?

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 4, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2015:00:04/27/15', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<java>', 'Title': 'How to invoke a java-method which name is set in a .properties file', 'ViewCount': 509, 'id': 29886435, 'user_AboutMe': None, 'user_AccountId': 4223957.0, 'user_DisplayName': 'user3457958', 'user_Reputation': 3.0, 'user_Views': 2.0, 'user_id': 3457958.0}}