help: reading xml from .jar - path issues.

P

Piper707

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top