Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAR Problems

 
Ronnie Coh
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi - I have JAR file that uses data files and two zipped files, but I can not get them to work. Every thing works file in my IDE when I work with JAR's files and the zipped files.

At first I included all the files in the JAR and used a Manifest file:

Main-Class: folder.mainName
Class-Path: folder.zipFile_1.zip folder.zipFile_2.zip

First the JAR would not read the dat files in the JAR. It did work when I put the data files in the JAR's folder.

a) Is there a way to get the JAR to read text files within the JAR.?


The JAR would not access the zip files. I reied putting them out side the JAR and changed the Manifest file without too much luck. Here is the file:

Main-Class: folder.mainName
Class-Path: zipFile_1.zip folderFile_2.zip

b) How can I get the JAR to read/use the resources in the zipped file?

Any help/suggestions would be appreciated. Thanks... Ronnie
 
Layne Lund
Ranch Hand
Posts: 3061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It probably depends on what you want to do with these files. As for the text files, you can use Class.getResource() to obtain a URL to the files inside the JAR. You can then easily obtain input and output streams for the URL. This will work for zip files as well as long as you are streaming the resources yourself. See the Java API docs for the java.lang.Class and java.net.URL classes and java.io package more details.

HTH

Layne
 
Ronnie Coh
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks - The two zipped files have printpreview classes. I can use them with the IDE but not standalone. The text file is input/lookup files. Thanks again.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic