How to execute a method of the class loaded

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: How to execute a method of the class loaded

Hybrid View

  1. #1
    Join Date
    Nov 2005

    How to execute a method of the class loaded


    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.saveRating(); This is not executing throwing an error no method.



  2. #2
    Join Date
    Oct 2005
    I think you need to cast it to the class like so...

    Class eancRatingHelper = Class.forName(helperClass);
    eancRatingHelper eancRH = (eancRatingHelper)eancRatingHelper.newInstance();

    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

  1. Replies: 2
    Last Post: 11-10-2005, 01:33 PM
  2. Return an array from a class method
    By nubira in forum C++
    Replies: 5
    Last Post: 11-04-2005, 02:53 PM
  3. Execute method from string
    By jk1121 in forum VB Classic
    Replies: 2
    Last Post: 07-31-2001, 03:32 PM
  4. Replies: 3
    Last Post: 04-13-2001, 09:13 PM
  5. Calling base class methods
    By GR in forum Java
    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
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center