This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
well the following code is for reflection class at location "D:\mycode\java\source\reflection.java"
well the following code is for myclass.java class at location "C:\java\classess\myclass.class"
NOW THE PROBLEM:
if .class files of both classess are in same directory it works fine but if both classes are at diffrent locations then the showConstructor methode just outputs first two constructors, the showMethods method just outputs main method and showFields method dont display any of its public or private member.
i am extremely worried anyone please help me out.
all kinds of suggestions and solutions are warmly welcome.
First of all, post real code. What you've shown here won't quite compile and wouldn't run. outputdir is never set, and there's a variable "myclass" that's never defined.
Second, classes are loaded by fully-qualified name. You've put "myclass" into "mypkg", but then talk about putting class files into paths that don't include the package directory. I don't know whether you're trying to load "mypkg.myclass" or just "myclass". It matters! Because this code glosses over all these significant points, it's hard to offer much in the way of help.
But finally -- and I'm sure that this is tied up with the first two points -- the only way this would happen is if you've got more than one "myclass.class' laying around. Perhaps there's one somewhere on your classpath from an earlier experiment. Use your operating system's "search" function to find and delete any old myclass.class files, and I suspect you'll start getting error messages that will point you to the real problem.
i will definately work upon your suggestions and will let you know the output.
Againg Thanks Alot
with Kind Regards Amir Iqbal
Joined: Jun 23, 2007
Thumbs Up for the ERNEST. your solution works man yess this thing does matter when you are invoking / loading a class that is that class is in a package or not ?? if yess then you have to call it by appending the package names in respective order for example testpkg.MyClass , com.mis.InfoClass etc etc