Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > help: reading xml from .jar - path issues.

Reply
Thread Tools

help: reading xml from .jar - path issues.

 
 
Piper707@hotmail.com
Guest
Posts: n/a
 
      06-06-2006
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
UnauthorizedAccessException when reading XML files (no problem when reading other file-types) blabla120@gmx.net ASP .Net 0 09-15-2006 02:08 PM
Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser) Erik Wasser Perl Misc 5 03-05-2006 10:09 PM
Server.MapPath() croaking with "failed to map path", but path is legal awbacker@gmail.com ASP .Net 0 05-12-2005 10:50 PM
Bizzare: Invalid path to Access mdb, path is good Keith-Earl ASP .Net 1 05-03-2004 03:25 PM
Tomcat returning 404 error when using additional path (/servlet/myServlet/extra/path/info) Mupota Muchelemba Java 1 02-04-2004 12:43 AM



Advertisments