| Author |
Getting information about where class file is stored based on object
|
Harish Tiruvile
Ranch Hand
Joined: Dec 01, 2005
Posts: 99
|
|
Hi all Is it possible to retrive information about where class file is stored in my system\computer based on Object reference.. I mean i am having an object say "Student" through java program i should print where exactly that Student.java file is placed in my system like C:\javaprgs\Student.java Is it possible to do so?...
|
Giving up is the easiest thing in the world to do..but holding it together when everything seems like falling apart is true strength!!
with regards, Harish.T
|
 |
Peter Chase
Ranch Hand
Joined: Oct 30, 2001
Posts: 1970
|
|
Generally, no, you simply can't get that information. Java does not store the path of the original source file in the class. In theory, I suppose, one might be able to write a custom ClassLoader that would make this type of thing possible. You'd have to [i]really[/] need the facility, before that was worthwhile, I'd say. Can you explain what you are trying to achieve, in case there is another approach that would be better?
|
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.<br /> <br />#:^P
|
 |
Harish Tiruvile
Ranch Hand
Joined: Dec 01, 2005
Posts: 99
|
|
Thank you Peter, While reading already written java codes i am spending more time in searching for exact file path(because in import they have used .* and i am having many import statements)..so i want to create a program which helps me in finding out class path (just by giving Object instance)
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24057
|
|
|
It sounds like what you need is to use a better editor or development environment. All serious Java programmer's editors and especially all IDEs let you click on an imported class name and automatically open that source file in the editor. Time to retire Notepad, and move to, for example Eclipse.
|
[Jess in Action][AskingGoodQuestions]
|
 |
 |
|
|
subject: Getting information about where class file is stored based on object
|
|
|