Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add a java class to a folder within a jar file

Tags:

java

windows

jar

using jar on the windows command prompt, how can I add foo.class to a folder "classes" in foo.jar?

I can add the file to the jar using

jar uvf foo.jar foo.class

but that doesn't put the class in the "classes" folder in the jar.

I know I can use winzip to unzip the jar, add the file, and zip it up again, but that's slow and hopefully unnecessary.

like image 202
Ian Cohen Avatar asked Jun 25 '09 14:06

Ian Cohen


1 Answers

Put foo.class into a classes directory, then run

jar uvf foo.jar classes/foo.class

(I've just tried it to make sure it works. There may a way of doing it without creating the classes directory, but I think this is the simplest solution.)

like image 125
Jon Skeet Avatar answered Oct 24 '22 00:10

Jon Skeet