Reputation: 38988
I've Goog'd but I can't find any third party library that will let you create a jar file programmatically. I amazed that even Apache commons-io doesn't seem to have such functionality.
I'd rather not implement it myself as the API is rather low level. Are there any 3rd party libraries out there that will do the job?
Edit: I meant programmatically in Java. I don't want to drop out to the shell and I don't want to work with java.io.*.
Upvotes: 1
Views: 615
Reputation: 80194
I'd suggest you look at JBOSS Arquillian. It provides a fluent interface to create jar, war, ear etc. See sample below
Archives.create("test.jar", JavaArchive.class)
.addClasses(
GreetingManager.class,
GreetingManagerBean.class);
Upvotes: 0
Reputation:
You don't need a third party library. It's all built into Java (the jar command just uses those classes)
http://download.oracle.com/javase/6/docs/api/java/util/jar/package-summary.html
Edit:
It will require you to still work with java.io.* as that is the only way to create files...
Upvotes: 2
Reputation: 39780
I'm not sure what you mean by "creating a jar file" but ant has a jar task which will create a jar file for you
Upvotes: 3
Reputation: 7466
http://download.oracle.com/javase/1.4.2/docs/tooldocs/windows/jar.html
Upvotes: 2