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

Accessing resources outside of the Jar

 
ahmet akin
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry i needed to format the directory structure:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic