C:\Program Files (x86)\Java\jdk1.8.0_102\bin>jar -h Illegal option: h Usage: jar {ctxui}[vfmn0PMe] [jar-file] [manifest-file] [entry-point] [-C dir] files ... Options: -c create new archive -t list table of contents for archive -x extract named (or all) files from archive -u update existing archive -v generate verbose output on standard output -f specify archive file name -m include manifest information from specified manifest file -n perform Pack200 normalization after creating a new archive -e specify application entry point for stand-alone application bundled into an executable jar file -0 store only; use no ZIP compression -P preserve leading '/' (absolute path) and ".." (parent directory) components from file names -M do not create a manifest file for the entries -i generate index information for the specified jar files -C change to the specified directory and include the following file If any file is a directory then it is processed recursively. The manifest file name, the archive file name and the entry point name are specified in the same order as the 'm', 'f' and 'e' flags. Example 1: to archive two class files into an archive called classes.jar: jar cvf classes.jar Foo.class Bar.class Example 2: use an existing manifest file 'mymanifest' and archive all the files in the foo/ directory into 'classes.jar': jar cvfm classes.jar mymanifest -C foo/ . C:\Program Files (x86)\Java\jdk1.8.0_102\bin> C:\Users\chenjo>jar -h 非法選項: h 用法: jar {ctxui}[vfmn0PMe] [jar-file] [manifest-file] [entry-point] [-C dir] files ... 選項: -c 建立新檔案 -t 列出檔案目錄 -x 從檔案中提取指定的 (或全部) 文件 -u 更新現有檔案 -v 在標準輸出中生成詳細輸出 -f 指定檔案文件名 -m 包含指定清單文件中的清單信息 -n 建立新檔案後執行 Pack200 規範化 -e 爲捆綁到可執行 jar 文件的獨立應用程序 指定應用程序入口點 -0 僅存儲; 不使用任何 ZIP 壓縮 -P 保留文件名中的前導 '/' (絕對路徑) 和 ".." (父目錄) 組件 -M 不建立條目的清單文件 -i 爲指定的 jar 文件生成索引信息 -C 更改成指定的目錄幷包含如下文件 若是任何文件爲目錄, 則對其進行遞歸處理。 清單文件名, 檔案文件名和入口點名稱的指定順序 與 'm', 'f' 和 'e' 標記的指定順序相同。 示例 1: 將兩個類文件歸檔到一個名爲 classes.jar 的檔案中: jar cvf classes.jar Foo.class Bar.class 示例 2: 使用現有的清單文件 'mymanifest' 並 將 foo/ 目錄中的全部文件歸檔到 'classes.jar' 中: jar cvfm classes.jar mymanifest -C foo/ .
$ jar tvf cos-26Dec2008.jar | grep Daemon.class 1790 Tue Nov 12 23:46:32 CST 2013 com/oreilly/servlet/Daemon.class $ jar tvf cos-26Dec2008.jar | grep Daemon.class | awk '{print $8}' com/oreilly/servlet/Daemon.class $ jar tvf cos-26Dec2008.jar | grep Daemon.class | awk '{print $8}'| xargs dirname com/oreilly/servlet $ jar tvf cos-26Dec2008.jar | grep Daemon.class | awk '{print $8}'| xargs dirname | xargs mkdir -p
部署在 Google雲裏的應用忽然有一個類作了修改,刪除掉從新上傳的話,一個jar包傳上去就得等半小時,牆有點高,你懂的,因此要是能單獨更新某個class文件就最棒了,方法固然是有的,以下所示。app
jar tvf test.jar | less // OR: unzip -v test.jar | grep xxx
經過上面命令搜索出本身要更新的class文件的目錄,在當前路徑下創建好目錄less
mkdir -p BOOT-INF/classes/net/yuxianghe/core/ cp Test.class BOOT-INF/classes/net/yuxianghe/core/
要更新的class的目錄創建好了以後直接更新到jar裏便可,以下命令所示:ui
jar -uvf test.jar BOOT-INF/classes/net/yuxianghe/core/Test.class
到這裏就作到了只更新jar包裏的單個類文件code