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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Reflection Code Problem" Watch "Reflection Code Problem" New topic
Author

Reflection Code Problem

Amir Iqbal
Ranch Hand

Joined: Jun 23, 2007
Posts: 97
hi to everyone !

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.

Thanks in advance.

REGARDS
[ November 21, 2008: Message edited by: Martijn Verburg ]

i am Java +ve Now !
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hi Amir, please do use UseCodeTags to highlight your code in future, I've done it for you in this case


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Amir Iqbal
Ranch Hand

Joined: Jun 23, 2007
Posts: 97
ok i will.
Thanks alot Martijn.

Regards
Amir Iqbal
Ranch Hand

Joined: Jun 23, 2007
Posts: 97
is this thread still alive???
i am waiting for response....
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

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.


[Jess in Action][AskingGoodQuestions]
Amir Iqbal
Ranch Hand

Joined: Jun 23, 2007
Posts: 97
Thanks alot Ernest for your kind Help.

i will definately work upon your suggestions and will let you know the output.

Againg Thanks Alot

with Kind Regards
Amir Iqbal
Amir Iqbal
Ranch Hand

Joined: Jun 23, 2007
Posts: 97
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

and thanks alot to all of you.
you guys Rock.

Regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reflection Code Problem
 
Similar Threads
help solving dynamic method invocation exception.
ClassLoader question
Problem with Reflection
equals()
HashMap