File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Applets and the fly likes Programmatically inserting into a jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Programmatically inserting into a jar" Watch "Programmatically inserting into a jar" New topic
Author

Programmatically inserting into a jar

Tom Fotherby
Greenhorn

Joined: May 31, 2002
Posts: 3
How do I insert a file into a preexisting jar file programmatically?
Background. I want an applet to load an XML file and the only way I can easily read the XML is using this.getClass().getResourceAsStream("backup_specFile.XML");
This is fine except the XML file is created dynamically after the program is all jarred up. So I need to insert the XML file into the jar.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Why does it have to be IN the jar. Couldn't it just be in the classpath? Of course you would need to be sure that there was not another file with the same name that was IN the jar.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Tom Fotherby
Greenhorn

Joined: May 31, 2002
Posts: 3
Aren't classpaths irrelevant to applets? To read in a file from an applet I thought that the only thing to do was to include the file inside the applet jar file and use
Inputstream usethis.getClass().getResourceAsStream("specFile.XML");
Any other suggestions to read in a file from applets would be welcome
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Ah - that little "applet" word.
Let's tranfer this to the Applets forum and see what they say.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Programmatically inserting into a jar
 
Similar Threads
How to create a jar file of a java project that uses Derby database
Remove first three bytes in a file.
XML to database
Storing parsed XML data into database
xml conversion