#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2005
    Posts
    8
    Rep Power
    0

    Path to file in JAR


    Hi,

    I've got xml files in my source folder which I want to add to a JAR file. However when I added them to the JAR and put add the JAR to the build path, the paths which previous pointed to these files now throw "file not found" exceptions. Therefore the path that throws the error is

    url="/WEB-INF/src/definition.xml"

    I'm just wondering what should I change the path to so that it can reference my xml file in the JAR

    Thanking you in advance

    Mike
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    100
    Rep Power
    13
    how are you trying to access the file?
  4. #3
  5. Indeed.
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Location
    D.C.
    Posts
    295
    Rep Power
    12
    To access a file inside a JAR, you need to create a URL, like so:

    Code:
    URL yourURL = Classname.class.getResource("path/to/your/file.xml");
    Last edited by Rambone; March 1st, 2006 at 08:44 AM.

IMN logo majestic logo threadwatch logo seochat tools logo