> I need to make the system class loader know about a class which isn't on the
> classpath, but is loaded at run time.
> Other classes on the classpath (and hence are loaded by system class loader)
> need to be able to use this runtime loaded class. How can I do this?
You can't. Every classloader has a place it gets its classes from. In
case of the system classloader and similar classloaders, this is a
classpath.
This is also the reason that if you define a data source for an
application, the application server must have the database driver in it's
classpath; not merely the application.
> A bit of background might help: I'm using JBoss with JFreeReport (the latter
> library isn't important). The JFreereport classes are on the classpath when
> JBoss is started, so everything can see them.
Which classloader has JFreeReport? Most application servers have a
classloader for itself (the system classloader), a classloader for all
applications, a classloader for each application and a classloader for
each component of an application (so a web application cannot access the
classes of the EJB component).
> However, JFreeReport cannot see classes which are deployed in jboss as
> (presumably) they will have to be loaded using a different class loader.
Correct.
> JFreereport is trying to load a couple of the deployed classes at runtime
> using Class.forName(), but cannot find the class, as it is trying to use the
> default class loader.
Not entirely. It asks it's own classloader. That classloader searches
its own classpath (or wherever it gets its classes from), and/or asks its
parent classloader (it can also ask its parent first, but I digress).
> I'm hoping that perhaps there is someway of 'adding' these classes to system
> class loader at run time so it will find them, tho I've had no luck so far.
There might be, but I don't know of any classloader inplementations that
allow this. First, you'll have to find out which classloader is being used
by JFreeReport (add your own class to that classpath, and ask that class).
Then, you'll have to find documentation for it, or decompile, and hope
there is a solution. It's a lot of work with little chance of success.
Check out my second paragraph (about data sources and database drivers).
It might give you a more feasible idea.

Signature
Oscar Kind http://home.hccnet.nl/okind/
Software Developer for contact information, see website
PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2