wood burning stoves 2.0*
The moose likes Java in General and the fly likes Related to java.lang.Reflect package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Related to java.lang.Reflect package" Watch "Related to java.lang.Reflect package" New topic

Related to java.lang.Reflect package

Indravadan T Patel

Joined: Sep 09, 2007
Posts: 29

I am trying to create the runtime object using the Constructor and Class. The code is just like that :

And i get the error :
Exception in thread "main" java.lang.ClassNotFoundException: A
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at indra.Test.main(Test.java:16)
Java Result: 1

Please let me know why that happens.

Indravadan Patel
[ July 10, 2008: Message edited by: David O'Meara ]
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

Please format your code and use code tags.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

You haven't really provided the details but
at indra.Test.main(Test.java:16)

says that your Test class has been packaged as 'indra', is the Class 'A' also packaged as 'indra'?
Class.forName requires the fully qualified class name, hence Class.forName("indra.A")
I agree. Here's the link: http://aspose.com/file-tools
subject: Related to java.lang.Reflect package