aspose file tools*
The moose likes JBoss/WildFly and the fly likes file access to deployed code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "file access to deployed code" Watch "file access to deployed code" New topic
Author

file access to deployed code

Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
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


Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5845
    
    7

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.


JBoss In Action
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
that's only useful for resources I know exist,

i would like to know what files are in the Jar,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: file access to deployed code