Re: i get java.lang.ClassNotFoundException wher i run my application
from JWS
On Jul 15, 12:57 am, markspace <nos...@nowhere.com> wrote:
...
The context class loader seems like the wrong idea to me,
From the JavaDocs..
"... The context ClassLoader is provided by the
creator of the thread for use by code running in
this thread when loading classes and resources. ..."
...but if it works, sure.
The context class loader (CCL) works more commonly
than using the default class loader. Try loading
an icon in main().
Little e.g., complete with build file and icon,
for less than 3Kb..
<http://pscode.org/eg/frameicon.zip>
..I'd just be concerned that the context class loader was
set to some other class loader (than the one returned by
getClass().getClassLoader()) and it would fail for some reason.
It is more the other way around. Using the default
class loader will fail in any number of situations,
especially with applets, JWS apps. and server code.
.. However
maybe applets guarantee that the context class loader will be set to the
correct loader to load the app's resources?
Not just applets, but most situations.
..I haven't seen that in any docs, ..
It is very poorly documented by Sun. :-/
Except for that one quote from the JavaDocs,
I cannot find much else in support of the CCL.
Sun's example code is notorious for using the
simpler construct you mentioned. But then,
many of Sun's example codes try to get to the
point the quickest way they can, and are not
necessarily good examples of doing much beyond
what the code is focusing on.
..but it might be true. Maybe Andrew knows something I don't.
I have run into this problem on a number of
occasions. The first and most irritating was
that I caould never manage to load a frame
icon, unless I (ended up) sub-classing (J)Frame.
Once called from inside the constructor, using
the default ..
this.getClass().getResource("the.gif");
... worked OK. But it does *not* work from the
main().
A variety of time, discussions and experiences
later, I tried again using the /CCL/ in main()
and finally, was able to manage the 'marvellous
technology' of finding an URL to a frame icon,
without sub-classing frame.
One discussion in relation to the CCL.
<http://forums.sun.com/thread.jspa?threadID=5355229>
...it also links back to another thread hereabouts.
And to he OP. No worries about the wrong button,
I figured it was something like that and you'd get
back to us here.
Glad you sorted it.
--
Andrew T.
pscode.org