aspose file tools*
The moose likes Beginning Java and the fly likes Accessing resources outside of the Jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Accessing resources outside of the Jar" Watch "Accessing resources outside of the Jar" New topic
Author

Accessing resources outside of the Jar

ahmet akin
Greenhorn

Joined: Oct 27, 2003
Posts: 14
Hello,

i package my stand alone application as a jar file. But while distributing it, i will provide some resource files outside of the jar file. (like index files directory for Lucene, some xml configuration files that can be changed runtime )
What is the way of accessing outside resources from a jar file? Lets say i have this structure

/myApp
/config
/indexes
/lib
/MyApp.jar
/Other jars that i use

inside the code, normally i access the resources with this.getClass.getResource(<relative path> ; or
this.getClass.getResource(<relative path> .getPath();

But when i pack it with jar, how will i lets say access to /config directory? when i stated the app from myApp/lib/MyApp.jar ? is there a resource finder, that i can use for accessing like "../config" within the code?
ahmet akin
Greenhorn

Joined: Oct 27, 2003
Posts: 14
Sorry i needed to format the directory structure:

 
jQuery in Action, 2nd edition
 
subject: Accessing resources outside of the Jar