• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to read config xml from a jar

 
Aju Josep
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am putting my config xml (config.xml) in a jar file (say MyConfig.jar) under a package "com.my.package". This jar is kept as a project utility jar under in my ear. Another utility jar (say MyUtil.jar) is having classes which need to read this xml. This jar is also kept as a project utility jar in the ear. The manifest of MyUtil.jar contains MyConfig.jar in the classpath. Now from a class within MyUtil.jar, how do i read config.xml ? I have tried the following.

(1)
InputStream ipStream = ClassLoader.getSystemResourceAsStream("com/my/package/config.xml");

--> this dosent work : after this statement is executed, ipStream is null.

(2)
String fileName = "com/my/package/config.xml";
InputStream ipStream = this.getClass().getResourceAsStream(fileName);

--> this dosent work : after this statement is executed, ipStream is null.

(3)
String fileName = "com/my/package/config.xml";
file = new File(fileName);
fileReader = new FileReader(file);
is = new InputSource(fileReader);

--> Dosent work either: says file not found.

Any idea, how to read the congif.xml file ???

Thanks,
Aju
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!