This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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")
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Related to java.lang.Reflect package
 
Similar Threads
main() & package question
Running Javaflow
.class files
Question on thread
Interface - AbstractClass Collision