help: reading xml from .jar - path issues.

Discussion in 'Java' started by Piper707@hotmail.com, Jun 6, 2006.

  1. Guest

    Hi,

    We need to read xml files that are packaged inside a .jar. The .jar
    lives in JBoss/server/default/lib/

    How can one access the xml files from any .class file within the .jar?

    If we use this approach:

    URL url = this.getClass.getResource("xmlFilePath");
    reader.read(url);

    This works fine if the path of the xml file to be read is under the
    path returned by this.getClass.getResource . But how does one access an
    xml file from a .class file that lives in a directory parallel to the
    xml file?

    We have tried editing the path returned by this.getClass.getResource
    and appending the correct path after it, but in spite of that, we get a
    FileNotFoundException.

    The only alternative we can think of now, is to have all the XMLFiles
    in one folder under a particular .class file. So that .class file will
    be used by anyone who needs to read an xml file.

    Are there any other ways to work around this?

    Thank for any help
    Rohit.
     
    , Jun 6, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arnold Peters
    Replies:
    0
    Views:
    587
    Arnold Peters
    Jan 5, 2005
  2. muttley
    Replies:
    0
    Views:
    2,731
    muttley
    Oct 20, 2005
  3. cyberco
    Replies:
    4
    Views:
    3,773
    Roedy Green
    Feb 14, 2006
  4. Arnold Peters
    Replies:
    0
    Views:
    670
    Arnold Peters
    Jan 5, 2005
  5. Raymond Schanks
    Replies:
    0
    Views:
    659
    Raymond Schanks
    Aug 3, 2010
Loading...

Share This Page