命令行删除或替换 jar 包中的文件
- Java
- 2018-06-21
- 169热度
- 0评论
这是一个简单又常用的操作,防止遗忘,记录一下吧。
用 zip -d 删除文件,用 jar -uf 更新文件。如果不先删除,直接 jar -uf,可能会有问题。
直接看例子:
➜ classes git:(master) ✗ ls
com fr-report-8.0.jar readme.md scripts
➜ classes git:(master) ✗ find . -name ProcessTaskImpl.class
./com/fr/web/core/process/reportprocess/ProcessTaskImpl.class
➜ classes git:(master) ✗ zip -d fr-report-8.0.jar com/fr/web/core/process/reportprocess/ProcessTaskImpl\$1.class
deleting: com/fr/web/core/process/reportprocess/ProcessTaskImpl$1.class
➜ classes git:(master) ✗ zip -d fr-report-8.0.jar com/fr/web/core/process/reportprocess/ProcessTaskImpl\$2.class
deleting: com/fr/web/core/process/reportprocess/ProcessTaskImpl$2.class
➜ classes git:(master) ✗ zip -d fr-report-8.0.jar com/fr/web/core/process/reportprocess/ProcessTaskImpl\$3.class
deleting: com/fr/web/core/process/reportprocess/ProcessTaskImpl$3.class
➜ classes git:(master) ✗ zip -d fr-report-8.0.jar com/fr/web/core/process/reportprocess/ProcessTaskImpl.class
deleting: com/fr/web/core/process/reportprocess/ProcessTaskImpl.class
➜ classes git:(master) ✗ jar -uf fr-report-8.0.jar com/fr/web/core/process/reportprocess/ProcessTaskImpl\$1.class
➜ classes git:(master) ✗ jar -uf fr-report-8.0.jar com/fr/web/core/process/reportprocess/ProcessTaskImpl\$2.class
➜ classes git:(master) ✗ jar -uf fr-report-8.0.jar com/fr/web/core/process/reportprocess/ProcessTaskImpl\$3.class
➜ classes git:(master) ✗ jar -uf fr-report-8.0.jar com/fr/web/core/process/reportprocess/ProcessTaskImpl.class