• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

file access to deployed code

 
Bill Shirley
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone hint me the best way to accessing a deployed jar as a resource?

I want to know the path of the jar my class was loaded in, so that I can parse the jar for annotated classes that may or may not yet be loaded.

JBoss 4.2.2

the system property java.class.path isn't getting me anywhere close:
/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/tools.jar:/usr/local/jboss-4.2.2.GA/bin/run.jar

the path i want to find (programatically, from the class) is similar to:
/usr/local/jboss-4.2.2.GA/server/default/deploy/mine.jar
 
Peter Johnson
author
Bartender
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:

this.getClass().getClassLoader().getResource("xxxxx");

or

Thread.getCurrentThread().getContextClassLoader.getResource("xxxxx");

That will help locate a resource (xxxx) in the same directory as the class making this call.
 
Bill Shirley
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that's only useful for resources I know exist,

i would like to know what files are in the Jar,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic