wood burning stoves 2.0*
The moose likes Java in General and the fly likes How to access non class files in a JAR Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to access non class files in a JAR" Watch "How to access non class files in a JAR" New topic
Author

How to access non class files in a JAR

Haricharan Ramachandra
Greenhorn

Joined: Feb 16, 2004
Posts: 28
Hi All

I have a situation, i am trying to create a JAR, with class files and XML files in it, which my other modules will be using (These are Junit test classes which will be using this). I have the classpath set in my ANT target, so i am able to access the class files, but it fails to read the XML file, i was of the impression we can have any file in the JAR file, can any one please share their experience in this regard.

Thanks in advance
Hari


Haricharan Ramachanra<br />SCJP 1.4<br />javaworks
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

You can, but you have to work with the correctly. You can open them using the Class.getResource() method (and related methods.)


[Jess in Action][AskingGoodQuestions]
Haricharan Ramachandra
Greenhorn

Joined: Feb 16, 2004
Posts: 28
Thanks for such a fast responce Ernest, really appriciate it. I guess my co-developers might not be nerv happy to make changes in their code,But i got a point to put across, thanks to you . so probably i will leave out the XML files from JAR for now.

regards
Hari
 
Don't get me started about those stupid light bulbs.
 
subject: How to access non class files in a JAR