Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / March 2005

Tip: Looking for answers? Try searching our database.

ClassNotFoundException when loading class via its own classLoader??

Thread view: 
F Da Costa Gomez - 21 Mar 2005 03:17 GMT
Hi,

I'v run into something quite puzzling (at least to me taht is ;-) ).

The following code gives me a ClassNotFoundException when i try to load Foo via
its own classloader.

ClassLoader cl = Foo.class.getClassLoader();
cl.loadClass("Foo")

Classloaders have never been my strong point but this is really beyond me.
Why is it throwing this exception?? What am i doing wrong\ not understanding?

tia,

Fermin DCG
Daniel Tahin - 21 Mar 2005 10:23 GMT
Hi!

Perhaps you should specifie the fully qualified name of Foo.class. Say
Foo.class is in package app, then try cl.loadClass("app.Foo") and invoke
java by specifying the path to the package app. So if app is located in
/home, then java -classpath /home  home.app.Foo

> Hi,
>
[quoted text clipped - 13 lines]
>
> Fermin DCG
F Da Costa Gomez - 21 Mar 2005 14:35 GMT
> Hi!
>
> Perhaps you should specifie the fully qualified name of Foo.class. Say
> Foo.class is in package app, then try cl.loadClass("app.Foo") and invoke
> java by specifying the path to the package app. So if app is located in
> /home, then java -classpath /home  home.app.Foo
Sorry, i forgot to mention that including the whole path.to.the.class indeed
does work. But i thought that using it without the path also worked or shouldn't it?

>> Hi,
>>
[quoted text clipped - 14 lines]
>>
>> Fermin DCG
Daniel Tahin - 21 Mar 2005 16:35 GMT
F Da Costa Gomez schrieb:

>> Hi!
>>
[quoted text clipped - 6 lines]
> indeed does work. But i thought that using it without the path also
> worked or shouldn't it?

I don't know. Perhaps by adding the path of Foo.class to the JVM's class
path, but i don't know, how to do this.

>>> Hi,
>>>
[quoted text clipped - 14 lines]
>>>
>>> Fermin DCG


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.