-
How to execute a method of the class loaded
Hi,
I have to execute the method of com.common.helper.EANCRatingHelper" + version
version may be 1,2, etc
if version = 1 the class is com.common.helper.EANCRatingHelper1;
Iam able to load the class using following code.But iam unable to execute the method of the above class
Can anybody help me how to execute the method of the class loaded.
Following is the code
String version = getHelperClassVersion(requestDate);
String helperClass = "com.redroller.common.carriers.eanc.helper.EANCRatingHelper" + version;
Class eancRatingHelper = Class.forName(helperClass);
eancRatingHelper.newInstance();
eancRatingHelper.saveRating(); This is not executing throwing an error no method.
thanks
Naveen
-
I think you need to cast it to the class like so...
Class eancRatingHelper = Class.forName(helperClass);
eancRatingHelper eancRH = (eancRatingHelper)eancRatingHelper.newInstance();
eancRH.saveRating();
newInstance returns an Object and you were not doing anything with it. Then you tryed to call saveRating as a static method of the class which it probably isn't.
I think this will work, but i haven't tried it so don't get mad if it doesn't.
Similar Threads
-
By fulcanelli in forum Java
Replies: 2
Last Post: 11-10-2005, 01:33 PM
-
Replies: 5
Last Post: 11-04-2005, 02:53 PM
-
By jk1121 in forum VB Classic
Replies: 2
Last Post: 07-31-2001, 03:32 PM
-
Replies: 3
Last Post: 04-13-2001, 09:13 PM
-
Replies: 1
Last Post: 11-09-2000, 05:38 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks