File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 24166
    
  30

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to access non class files in a JAR
 
Similar Threads
Jar files & JarOutputStream
jar files inside executable jar file
Playing sound from a jar file
Problem During Compilation of EJB Jar with Weblogic.ejbc tool
JAXM Applet Problem