• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HOW TO CREATE A .jar PROGRAMMATICALLY

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all ,

I was wondering if anyone could provide me with some help. I want to create a jar file programmatically. I know how to use the command line to create jar files, but i was wondering if anyone had a java program that read a directory and created a .jar File? Can anyone help please???!?!?!?

Thanks in advance,
DG
 
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A jar file a actually nothing more than a Zip file following a particular format. You can use the ZipOutputStream class to create a zip file.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's also java.util.JarOutputStream if you insist on a JAR with a manifest.
 
Manuel Moons
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just google on JarOutputStream and ZipOutputStream and I found a couple of examples.



JarOutputStream Example


ZipOutputStream Example


You can actually use both but JarOutputStream has some convenience methods to pass the manifest file. Remember though, a manifest file is just a text file so you can just as well add it using the ZipOutputStream.
reply
    Bookmark Topic Watch Topic
  • New Topic