Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
J2EE General J2EE (Java 2 Enterprise Edition) discussions. Questions not specific to EE will be redirected elsewhere.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the J2EE section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 26th, 2007, 04:44 AM
Registered User
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reading xml file which is in a JAR file

i have a jar with class files and xml files in it. my application uses this jar and a particular class has a link to the xml. but while compiling, it shows path not found. the application couldnt read the xml file in the jar. how to set the path or read the xml file

XML file in JAR:
SQLMaps/admin/sample.xml [folder structure inside the jar file]

my application has a path like SQLMaps/admin/sample.xml

but how do we point to the xml file in the jar


C ya
Old December 26th, 2007, 05:03 AM
Friend of Wrox
Join Date: Mar 2007
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post

The class which tries to read the xml or has the url to the xml and the xml files are in the same directory then try by giving just the xml file name. i think it'll look in the current directory
You can try by giving the complete path from the root package. Say you've the xml file in a directory com/abc/def/ghi.xml and the class which reads it is in package com.abc.def.JKL.java then try by giving the path /com/abc/def/ghi.xml.

Hope that solves your problem.

- Rakesh
Old December 26th, 2007, 05:52 AM
Registered User
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

thanks rakesh

but my question is

the jar file contains

i have an application which uses this jar. in my java file

the package structure of my application is

in this file i have to read the xml file which is in the jar file. i use tomcat and the lib contains the JAR file.

while reading, i have specified as ./sqlmaps/admin/sample.xml

but it cudnt recognize the xml in the jar file

C ya

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with PHP file reading XML file for output rydog65 Beginning PHP 0 March 26th, 2008 05:13 PM
reading a XML file connect2sandep XML 1 December 14th, 2006 04:50 AM
reading a XML file connect2sandep General .NET 0 December 13th, 2006 02:10 PM
Accessing properties file outside jar file anand_indya J2EE 0 December 8th, 2004 06:34 AM
Read XML Config File From Within EJB JAR leojhartiv J2EE 0 October 6th, 2003 03:08 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.