Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #28350

Re: limitations of Class.forName

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Robert Klemme <shortcutter@googlemail.com>
Newsgroups comp.lang.java.programmer
Subject Re: limitations of Class.forName
Date Fri, 02 May 2014 08:51:43 +0200
Lines 42
Message-ID <bsgtk1Fgig7U1@mid.individual.net> (permalink)
References <p5q5m916vc7ued437313f6ghvac4slirrq@4ax.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net EoMstJC0MYMWnPikV+HQiwly7Pg45Ot40LHw90Td1lD1J+afc=
Cancel-Lock sha1:kqlBrdcmUR4xem0HuifYvds86OQ=
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0
In-Reply-To <p5q5m916vc7ued437313f6ghvac4slirrq@4ax.com>
Xref csiph.com comp.lang.java.programmer:28350

Show key headers only | View raw


On 02.05.2014 02:42, Roedy Green wrote:
> When I first encountered Java, I was very excited about the notion
> of interfaces and dynamic loading. I thought it would let people plug
> in their own code to every conceivable utility.
>
> There are two catches.
>
> 1. arranging that java.exe will look for your dynamic class in the
> place where it is.  It will not usually be bundled in the original
> jar.

It's not only java.exe, but also java (on other platforms), java plugin etc.

> 2. arranging that java.exe will look for any auxiliary classes your
> plugin needs in the place where they live.
>
> A garden variety jar prevents java from looking anywhere else for
> classes.

You can have a classpath header in the JAR manifest.  You can use that 
to do relative references, i.e. via same directory or URL that hosts the 
referencing JAR.

> I thought I would write a short essay on this.  What techniques are
> available?

See Arne's reply.  Usually you configure the URL (or a directory name or 
...) and create a classloader or classloaders that will look there.

> I have always skirted the problem by putting all classes in the
> original jar.

I don't think that's a good idea because it makes composing of an 
application harder than necessary.

Also, various container systems have solved this already - you just need 
to look how JEE containers and Tomcat are doing things.

Cheers

	robert

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

limitations of Class.forName Roedy Green <see_website@mindprod.com.invalid> - 2014-05-01 17:42 -0700
  Re: limitations of Class.forName Arne Vajhøj <arne@vajhoej.dk> - 2014-05-01 21:15 -0400
  Re: limitations of Class.forName Robert Klemme <shortcutter@googlemail.com> - 2014-05-02 08:51 +0200
  Re: limitations of Class.forName Josip Almasi <joe@vrspace.org> - 2014-05-02 09:25 +0200
    Re: limitations of Class.forName Roedy Green <see_website@mindprod.com.invalid> - 2014-05-06 03:55 -0700

csiph-web