Skip to main content

Searching the classpath

1 reply [Last post]
keeskuip
Offline
Joined: 2003-06-17
Points: 0

I would like to have an api to search for
resources on the classpath.

For instance in my application I would like to
load all plugins. Plugins are class-files that
could be loaded with the following regular
expression 'plugins/*'.

Basically I would like that
ClassLoader.getResources(String resourceName) would
allow regular expression as a resourceName.

Kees

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mthornton
Offline
Joined: 2003-06-10
Points: 0

Some types of location which are permitted on a classpath are not necessarily searchable. Instead use a single resource name and find all instances of that name in your classpath using ClassLoader.getResources. These resources should list the plugins available.

This type of mechanism is alluded to here (a section of the documentation which could be greatly improved)

http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html#Service%20Provider

Also look at RFE 4640520 on the bug parade.

Message was edited by: mthornton