Results 1 to 6 of 6
  1. #1
    rnd
    rnd is offline Member
    Join Date
    Aug 2008
    Posts
    3
    Rep Power
    0

    Default Problem in Reflection API

    Hi All,
    I am using the Reflection API for the first time...
    can anybody help me in retrieving the package name if only name of a class is known in a program...
    for eg.
    if in my program i give String as an input.. my program should search for its package and display its all declared functions...

    thanks
    rnd

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    search for its package and display its all declared functions...
    Some confusion with the above. A package contains classes.
    A class has methods and fields.
    There are classes to access each of these.

    What classes and methods in the Class class have you tried so far? Have you written any code to see what you get back from the various Class methods?

  3. #3
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

  4. #4
    rnd
    rnd is offline Member
    Join Date
    Aug 2008
    Posts
    3
    Rep Power
    0

    Default

    No,
    actually i am making a program like eclipse where if for eg. i write
    Array a=new Array();
    aa.
    at dot a key event is generated at the text area... and it pops up all the methods of that class....
    i have used
    Class.forName(String) method for it, but it gives an exception ClassNotFound ... coz i am just passing "Array"and it needs the whole path as "java.util.Array"....

    So,I like my program to find "java.util" as soon as "Array" is given as an argument....

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    To find the path to a file, you'll need to search all paths to find it.
    Since the package is an unknown value, all possible paths will have to be searched.
    Perhaps you could presearch the jar file containing all the java classes and create a Hashtable with the class name as key and all the paths to that class as the value.

  6. #6
    rnd
    rnd is offline Member
    Join Date
    Aug 2008
    Posts
    3
    Rep Power
    0

Similar Threads

  1. Object Reflection: Setting value
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-23-2008, 08:13 PM
  2. Class Reflection: Is it an interface
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-23-2008, 08:10 PM
  3. Array Reflection: Multi Array Reflection
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-23-2008, 08:08 PM
  4. Getting method names using Reflection
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-24-2008, 03:18 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
  •