× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Sudha,

that is the similar thing to what I usually do.

I create a single record file 1000 chars long and read the classpath in from
that.
i just thought there might be cleaner way to load lots of jar files that
reside in a directory.

Heres the link to the custom classloader stuff.

http://www-106.ibm.com/developerworks/java/library/j-dyn0203.html

The class you create will subclass URLClassloader.
To load all the jars in a classpath, you just read them in from directory
and call addUrl to add the to the custom classloaders classpath

eg this code will add the jars in a list of directories to the classpath

 class JarFilter implements FilenameFilter {
     public boolean accept(File dir, String name) {
         return (name.endsWith(".jar"));
     }
 }


     // Create filter if necessary
     if (jf == null)
      jf = new JarFilter();

     String lib = null;

     StringTokenizer st = new StringTokenizer(liblist,":");
     while (st.hasMoreTokens()) {
         lib = st.nextToken();

      // Get a list of jars in the directory
      File dir = new File(lib);

      // Exit if directory not found
      if (!dir.exists())
      {
       throw new Exception(dir.getAbsolutePath() + " not found in
addJarLib");
      }

      File[] files = dir.listFiles(jf);
      if (files.length == 0)
      {
             addURL(dir.toURL());
      }
      else
      {
          for (int i = 0; i < files.length; i++) {
                 addURL(files[i].toURL());
       }
      }
     }

cheers
Colin.W




----- Original Message ----- 
From: <SRamanujan@xxxxxxxxxxxxxxxxxx>
To: <java400-l@xxxxxxxxxxxx>
Sent: Monday, August 30, 2004 8:58 PM
Subject: RE: Declaring Java classes and methods


> Hi Colin,
> I usually write a clle that sets up the class path env variable with the
> desired paths passed in from command.  But am curious about the custom
> classloader. Where can I find info on this?
> Thanks,
> Sudha
>
> Sudha Ramanujan
> SunGard Futures Systems
> sramanujan@xxxxxxxxxxxxxxxxxx
> (312) 577 6179
> (312) 577 6101 - Fax
>
> -----Original Message-----
> From: colin williams [mailto:colin.williams@xxxxxxxxxxxx]
> Sent: Monday, August 30, 2004 2:26 PM
> To: Java Programming on and around the iSeries / AS400
> Subject: Re: Declaring Java classes and methods
>
> Joe,
>
> if you need to write a custom classloader, there are some articles on
> the
> IBM developerworks site that discuss this(assuming you havent done this
> before!).
>
> I recently knocked up a custom classloader so that i could setup my
> classpath dynamically, rather than setting using the RUNJVA command.
>
> I had an application that used a component dependent on a lot of open
> source
> JARS, and I didnt want to type them all in to the classpath one by one.
> So I created custom classloader that I could point at a directory, and
> it
> would add all the jars to the classpath.
>
> cheers
> Colin.W
>
> ----- Original Message ----- 
> From: <furgalj@xxxxxxxxxxxxxxxx>
> To: <java400-l@xxxxxxxxxxxx>
> Cc: <java400-l@xxxxxxxxxxxx>; <java400-l-bounces@xxxxxxxxxxxx>
> Sent: Monday, August 30, 2004 3:36 PM
> Subject: Re: Declaring Java classes and methods
>
>
> > Joe Pluta wrote:
> >
> > >I'm a little unclear as to how tightly typed the type O variables
> are.
> > >If I declare a type O variable as class Widget, must I instatiate an
> > >object of type Widget to stick in there?  Can I use a subclass of
> > >Widget?  Can I use a class that's NOT a subclass, provided the method
> I
> > >later invoke has the same signature?
> > >
> > >I can do this with a factory method.  I'd have to instatiate the
> > >factory, and then pass the class name into the factory as a parameter
> to
> > >instantiate the actual object (or have a delegate method in the
> factory
> > >that emulates the desired method, only taking a class name as well).
> It
> > >would be a little easier if I could do it in the RPG, is all.
> >
> > Joe, maybe I'm stating the obvious here, and you've already looked
> into
> > this, but if not, it might be worth a try. I believe what you need is
> a
> > custom class loader. You can write them yourself if you study how Java
> > does it. This could be a static class and loader method, so that when
> you
> > called it with the class.method variable name it would not have to be
> > instantiated each time. You might even be able to do some of this in
> RPG,
> > but I'm not at all sure about that. But I have seen and heard of
> people
> > writing stranger class loaders than that -)! Also, as to your last
> point,
> > can't you define interfaces for the classes and methods you're
> interested
> > in ant invoke them via the interface method? By doing this you should
> be
> > able to slip in almost anything as long as the signature matches.
> >
> >
> > _________________________________________________________________
> > Jeff Furgal / MIMIX User Interface Product Architect / Lakeview
> Technology
> >
> > furgalj@xxxxxxxxxxxxxxxx / 630-282-8360
> >
> > LAKEVIEW TECHNOLOGY CONFIDENTIAL
> >
> > This e-mail may contain SECRET, PRIVILEGED AND/OR CONFIDENTIAL
> INFORMATION
> > intended only for the use of the addressee.  If you are not the
> addressee,
> > or the person responsible for delivering it to the person addressed,
> you
> > may not copy or deliver this to anyone else.  If you received this
> e-mail
> > in error, please immediately notify Lakeview by returning the original
> > message to the sender via e-mail.
> > --
> > This is the Java Programming on and around the iSeries / AS400
> (JAVA400-L)
> mailing list
> > To post a message email: JAVA400-L@xxxxxxxxxxxx
> > To subscribe, unsubscribe, or change list options,
> > visit: http://lists.midrange.com/mailman/listinfo/java400-l
> > or email: JAVA400-L-request@xxxxxxxxxxxx
> > Before posting, please take a moment to review the archives
> > at http://archive.midrange.com/java400-l.
> >
> >
>
>
> This e-mail has been sent by a company of Bertram Group Ltd, whose
> registered office is 1 Broadland Business Park, Norwich, NR7 0WF.
> This message, and any attachments, are intended solely for the addressee
> and may contain privileged or confidential information.  If you are not
> the intended recipient, any disclosure, copying, distribution or any
> action taken or omitted to be taken in reliance on it, is prohibited and
> may be unlawful.  If you believe that you have received this email in
> error, please contact the sender immediately. Opinions, conclusions and
> statements of intent in this e-mail are those of the sender and will not
> bind a Bertram Group Ltd company unless confirmed in writing by a
> director independently of this message.
> Although we have taken steps to ensure that this email and any
> attachments are free from any virus, we advise that in keeping with good
> computing practice the recipient should ensure they are actually virus
> free.
>
> --
> This is the Java Programming on and around the iSeries / AS400
> (JAVA400-L) mailing list
> To post a message email: JAVA400-L@xxxxxxxxxxxx
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/mailman/listinfo/java400-l
> or email: JAVA400-L-request@xxxxxxxxxxxx
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/java400-l.
>
>
> --
> This is the Java Programming on and around the iSeries / AS400 (JAVA400-L)
mailing list
> To post a message email: JAVA400-L@xxxxxxxxxxxx
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/mailman/listinfo/java400-l
> or email: JAVA400-L-request@xxxxxxxxxxxx
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/java400-l.
>
>


This e-mail has been sent by a company of Bertram Group Ltd, whose registered 
office is 1 Broadland Business Park, Norwich, NR7 0WF. 
This message, and any attachments, are intended solely for the addressee and 
may contain privileged or confidential information.  If you are not the 
intended recipient, any disclosure, copying, distribution or any action taken 
or omitted to be taken in reliance on it, is prohibited and may be unlawful.  
If you believe that you have received this email in error, please contact the 
sender immediately. Opinions, conclusions and statements of intent in this 
e-mail are those of the sender and will not bind a Bertram Group Ltd company 
unless confirmed in writing by a director independently of this message. 
Although we have taken steps to ensure that this email and any attachments are 
free from any virus, we advise that in keeping with good computing practice the 
recipient should ensure they are actually virus free.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.