Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reflection Code Problem

 
Amir Iqbal
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amir, please do use UseCodeTags to highlight your code in future, I've done it for you in this case
 
Amir Iqbal
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok i will.
Thanks alot Martijn.

Regards
 
Amir Iqbal
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is this thread still alive???
i am waiting for response....
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Amir Iqbal
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic