Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Finding absolute path of imported class within program

 
Greg Donahue
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Greg Donahue
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I owe you my thanks.
This worked perfectly. A URL was sufficient.
-Greg
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic