aspose file tools*
The moose likes Java in General and the fly likes Finding absolute path of imported class within program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Finding absolute path of imported class within program" Watch "Finding absolute path of imported class within program" New topic
Author

Finding absolute path of imported class within program

Greg Donahue
Greenhorn

Joined: Oct 07, 2003
Posts: 24
Hi there,
Is there any "quick and dirty" solution that lets you examine an instance of an imported class within a running executable and determine where that class's .class file sits on the file system? Is there some way to take an instance of the Class class or the ClassLoader class and produce a File object? I'm looking for a solution that works within the program itself...I cannot check the classpath and I cannot grep the system.
Any help is appreciated,
-Greg


vi veri veniversum vivus vici
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
This seems to work:

If you want a File object - that could be tough, considering the .class file may well be inside a jar file. Is getting a URL good enough?
[ October 08, 2003: Message edited by: Jim Yingst ]

"I'm not back." - Bill Harding, Twister
Greg Donahue
Greenhorn

Joined: Oct 07, 2003
Posts: 24
I owe you my thanks.
This worked perfectly. A URL was sufficient.
-Greg
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Finding absolute path of imported class within program