Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

anyone work with classloaders?

  Asked By: Kenneth    Date: Jun 18    Category: Java    Views: 608

I'd like to be able to programically find a class without having to set the
classpath variable. For example, I know i'm going to have a /lib directory with
an arbitary number of jar files in it. I'd like to NOT set each jar file with
the -classpath switch when I run my application. Instead I want the application
to look in the lib directory and get what's there.

My first thought was to try to change the value of
System.getProperty("java.class.path"). Although I can change the value, the
classes are not found. Anyone have a small example of how to do this?



3 Answers Found

Answer #1    Answered By: Aaliyah Khan     Answered On: Jun 18

Actually, you will probably need to create a custom class  loader.
Here's an example  which I use on a regular basis:


Answer #2    Answered By: Maurice Hanson     Answered On: Jun 18

Can you replace the default class  loader with this one? Or do you normally just
create an instance of this object and use it directly?

Answer #3    Answered By: Bellona Lopez     Answered On: Jun 18

I don't think you can replace the default class  loader. I usually just
use it directly.

Didn't find what you were looking for? Find more on anyone work with classloaders? Or get search suggestion and latest updates.