This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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
Author

Related to java.lang.Reflect package

Indravadan T Patel
Greenhorn

Joined: Sep 09, 2007
Posts: 29
Hi,

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.

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

Joined: Mar 06, 2001
Posts: 13459

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

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")
 
GeeCON Prague 2014
 
subject: Related to java.lang.Reflect package