aspose file tools
The moose likes Java in General and the fly likes Getting information about where class file is stored based on object Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Getting information about where class file is stored based on object" Watch "Getting information about where class file is stored based on object" New topic
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
    
  13

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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting information about where class file is stored based on object
 
Similar Threads
.preperties file
Where did you store your reserved flight data?
Polymorphics and Generics.... how to do specific things to a subclass
Deserialize object - Class unknown
Enycrypting and serialisation