Find all classes defined in a package using reflection?

Discussion in 'Java' started by guava, Aug 8, 2003.

  1. guava

    guava Guest

    Is there any way that I can find all classes belong to a package?

    Suppose that I have three class in my classpath say
    mypack.A, mypack.B, and mypack.C.

    Is there anyway I can reflect things as

    Class[] getCalssesInPackage(Class c);

    Thanks for any help.
     
    guava, Aug 8, 2003
    #1
    1. Advertising

  2. On 8 Aug 2003 12:27:16 -0700, (guava) wrote:

    > Is there any way that I can find all classes belong to a package?
    >
    > Suppose that I have three class in my classpath say
    > mypack.A, mypack.B, and mypack.C.
    >
    > Is there anyway I can reflect things as
    >
    > Class[] getCalssesInPackage(Class c);


    No. the best you can do is go through each of the directories and
    jar/zip files in the classpath and look for matches. This will
    not find you classes that have custom loaders which were found
    through some other means.

    --Joe
     
    Joseph Millar, Aug 8, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeffy
    Replies:
    2
    Views:
    2,687
    Thomas Weidenfeller
    Sep 10, 2003
  2. Carfield Yim
    Replies:
    1
    Views:
    1,485
    Andrew Thompson
    May 31, 2004
  3. Julian
    Replies:
    3
    Views:
    4,563
    Thomas Schodt
    Apr 30, 2005
  4. Oodini
    Replies:
    1
    Views:
    1,795
    Keith Thompson
    Sep 27, 2005
  5. Jason Cavett
    Replies:
    18
    Views:
    1,339
    Jason Cavett
    Mar 26, 2007
Loading...

Share This Page