• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reflection Code Problem

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok i will.
Thanks alot Martijn.

Regards
 
Amir Iqbal
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is this thread still alive???
i am waiting for response....
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic