• Post Reply Bookmark Topic Watch Topic
  • New Topic

HOW TO CREATE A .jar PROGRAMMATICALLY  RSS feed

 
Durand Grimmett
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • 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
 
Manuel Moons
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • 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.
 
Joe Ess
Bartender
Posts: 9439
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!