How to add a class to an existing JAR file.

Say we have a jar file start.jar and want to add a class to it.


$ mkdir jarbuild
$ cp start.jar jarbuild
$ cd jarbuild
$ jar -xf start.jar
$ rm start.jar
$ cp -r ~/secmgr .
$ find secmgr/
secmgr/
secmgr/manager
secmgr/manager/ProfilingSecurityManager.class
$ jar cmf META-INF/MANIFEST.MF mystart.jar *

Now you have a new jarfile that's the same as start.jar but with the ProfilingSecurityManager class in it. If you want, you can:


$ mv mystart.jar ../start.jar