aspose file tools*
The moose likes Java in General and the fly likes Java Reflection class not found problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java Reflection class not found problem" Watch "Java Reflection class not found problem" New topic
Author

Java Reflection class not found problem

andrea casini
Greenhorn

Joined: Jul 27, 2010
Posts: 13
Hello to everyone.

I am experiencing a really annoying problem when using reflection. I have this simple code:


I took this example from the official guide but when I run this in Netbeans 6.9.1 it return a "ClassNotFoundException".. WTF the class A is there!! Why is this happen?
I believe it has something to do with netbeans.

Please help.

Thanks
Markas Korotkovas
Greenhorn

Joined: Jan 27, 2011
Posts: 21

are you using default package? if not you need to specify fully qualified name for A when doing the Class.forName("...")
andrea casini
Greenhorn

Joined: Jul 27, 2010
Posts: 13
Markas Korotkovas wrote:are you using default package? if not you need to specify fully qualified name for A when doing the Class.forName("...")


Ok.. The class is in "build/classes/model/". But I don't know the sintax to specify the classpath in the "forName" method. Could you please tell me how?
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

if the class is on the model directory then it should have

at the start of the class file.
The fully qualified class name is now model.A
You refer to the class in Class.forName() using the fully qualified class name ie Class.forName("model.A")
andrea casini
Greenhorn

Joined: Jul 27, 2010
Posts: 13
Damn it was so simple..

Thank you..
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

No one said things have to be hard. Reflection is a great tool.
Good job
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Reflection class not found problem
 
Similar Threads
isinstance
Short-Circuit Operators.....
operators
comparing Boolean wrappers objects
how to compile java source code with assertion ?