Just zip it all up, a jar is just a zip file.
- Unzip .jar
- Change class
- Converts the entire structure to .zip
- Rename it to .jar
- There you go.
You can automate it using the ant <jar> task.
As stated below, you can use the jar tool that comes with the JDK installation. jar -xvf your.jar to extract and jar -cvf your.jar inputfiles . See the documentation.
What makes an executable JAR file consists in that it contains in its structure a file located in META-INF/MANIFEST.MF , which describes what an entry point class is, for example:
Manifest-Version: 1.0 Main-Class: foo.bar.FooBar
Alex
source share