Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Finding all of the classes in a package

Reply
Thread Tools

Finding all of the classes in a package

 
 
Jerald
Guest
Posts: n/a
 
      02-17-2005
I'm trying to build a flexible plugin structure and it seems like a good
way would be to include each plugin class in a package.

That assumes, of course, that there is some way to discover what classes
exist in the package. So far I cannot find anything in the ClassLoader,
Class or Package specs that would obviously do that. Any methods I can
find require me to know the name of the class I want to load.

Am I barking up the wrong tree? Is there another good way to go about this?

Thank you
Rich
 
Reply With Quote
 
 
 
 
Chris Smith
Guest
Posts: n/a
 
      02-17-2005
Jerald <> wrote:
> I'm trying to build a flexible plugin structure and it seems like a good
> way would be to include each plugin class in a package.


Certainly plugins can be placed into packages. It sounds, though, as if
you're trying to be too restrictive on the way plugins are written.
Enforcing a rule of one package per plugin class is forced and
unnatural, not to mention completely unnecessary.

> That assumes, of course, that there is some way to discover what classes
> exist in the package. So far I cannot find anything in the ClassLoader,
> Class or Package specs that would obviously do that. Any methods I can
> find require me to know the name of the class I want to load.


There is no such thing. It is a fundamental concept of Java class
loading that you must first know the name of the class you want, and
then load the class.

> Am I barking up the wrong tree? Is there another good way to go about this?


Yes, you are barking up the wrong tree. The right way to do this
depends on exactly what you want. Ideally, plugins would be distributed
as JAR files, and you'd read some fixed thing in the JAR file (perhaps
the manifest) to discover the name of the plugin class. That seems to
be the best way overall.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Reply With Quote
 
 
 
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      02-17-2005
Jerald wrote:
> That assumes, of course, that there is some way to discover what classes
> exist in the package.


No, you can not. This is discussed several times a month Go read an
archive of the group.

/Thomas

--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/...g/java/gui/faq
 
Reply With Quote
 
Jerald
Guest
Posts: n/a
 
      02-18-2005
Thank you. Actually I found the FAQs but didn't find the archive. Could
you please point me at it?



Thomas Weidenfeller wrote:
> Jerald wrote:
>
>> That assumes, of course, that there is some way to discover what
>> classes exist in the package.

>
>
> No, you can not. This is discussed several times a month Go read an
> archive of the group.
>
> /Thomas
>

 
Reply With Quote
 
Tilman Bohn
Guest
Posts: n/a
 
      02-18-2005
In message <lZCdnXBmst47oYjfRVn->,
Jerald wrote on Thu, 17 Feb 2005 19:53:58 -0500:

> Thank you. Actually I found the FAQs but didn't find the archive. Could
> you please point me at it?


groups.google.com?

--
Cheers, Tilman

`Boy, life takes a long time to live...' -- Steven Wright
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
List All Classes In A Package Jason Teagle Java 12 06-13-2008 11:19 PM
Debate: Inner classes or public classes with package access? Christian Bongiorno Java 5 08-30-2004 08:14 AM
Can I using reflection to get all child classes or classes undera package dynamically? Carfield Yim Java 1 05-31-2004 05:33 PM
Finding all Classes of a Package Wolfgang Heintz Java 7 10-06-2003 08:00 AM
Find all classes defined in a package using reflection? guava Java 1 08-08-2003 08:38 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57