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.
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
posted
0
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?
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")