jar的全称:JavaTM Archive (JAR) file,是java存档文件。
用于java 的class等文件压缩打包
用法:jar {ctxu}[vfm0Mi] [jar-文件] [manifest-文件] [-C 目录] 文件名 ...
选项:
-c 创建新的存档
-t 列出存档内容的列表
-x 展开存档中的命名的(或所有的〕文件
-u 更新已存在的存档
-v 生成详细输出到标准输出上
-f 指定存档文件名
-m 包含来自标明文件的标明信息
-0 只存储方式;未用zip压缩格式
-M 不产生所有项的清单(manifest〕文件
-i 为指定的jar文件产生索引信息
-C 改变到指定的目录,并且包含下列文件:
打包当前目录下的class:
进入当前目录,
输入 jar -cvf .jar Test1.class, Test2.class
打包webapps/myapp为一个war发布包:
进入 webapps/myapp
输入jar -cvf myapp.war *
这里生成的war可以发布到tomcat/webapps或者webshphere
jar基本操作:
1. 创建jar文件
jar cf jar-file input-file(s)
c---want to Create a JAR file.
f---want the output to go to a file rather than to stdout.
v---Produces verbose(详细的) output.
eg:
1)jar cf myjar.jar query_maintain_insert.htm
2)jar cvf myjar.jar query_maintain_insert.htm
3)jar cvf myjar.jar query_maintain_insert.htm mydirectory
4)jar cv0f myjar.jar query_maintain_insert.htm mydirectory
0---don't want the JAR file to be compressed.
5)jar cmf MANIFEST.MF myjar.jar yahh.txt
m---Used to include manifest information from an existing manifest file.
6)jar cMf MANIFEST.MF myjar.jar yahh.txt
M---the default manifest file should not be produced.
7)jar cvf myjar.jar *
*---create all contents in current directory.
2. 察看jar文件
jar tf jar-file
t---want to view the Table of contents of the JAR file.
eg: 1)jar vft yahh.jar
v---Produces verbose(详细的) output.
3. 提取jar文件
jar xf jar-file [archived-file(s)]
x---want to extract files from the JAR archive.
eg: 1)jar xf yahh.jar yahh.txt(仅提取文件yahh.txt)
2)jar xf yahh.jar alex/yahhalex.txt(仅提取目录alex下的文件yahhalex.txt)
3)jar xf yahh.jar(提取该jar包中的所有文件或目录)
4. 修改Manifest文件
jar cmf manifest-addition jar-file input-file(s)
m---Used to include manifest information from an existing manifest file.
5. 更新jar文件
jar uf jar-file input-file(s)
u---want to update an existing JAR file.
用于java 的class等文件压缩打包
用法:jar {ctxu}[vfm0Mi] [jar-文件] [manifest-文件] [-C 目录] 文件名 ...
选项:
-c 创建新的存档
-t 列出存档内容的列表
-x 展开存档中的命名的(或所有的〕文件
-u 更新已存在的存档
-v 生成详细输出到标准输出上
-f 指定存档文件名
-m 包含来自标明文件的标明信息
-0 只存储方式;未用zip压缩格式
-M 不产生所有项的清单(manifest〕文件
-i 为指定的jar文件产生索引信息
-C 改变到指定的目录,并且包含下列文件:
打包当前目录下的class:
进入当前目录,
输入 jar -cvf .jar Test1.class, Test2.class
打包webapps/myapp为一个war发布包:
进入 webapps/myapp
输入jar -cvf myapp.war *
这里生成的war可以发布到tomcat/webapps或者webshphere
jar基本操作:
1. 创建jar文件
jar cf jar-file input-file(s)
c---want to Create a JAR file.
f---want the output to go to a file rather than to stdout.
v---Produces verbose(详细的) output.
eg:
1)jar cf myjar.jar query_maintain_insert.htm
2)jar cvf myjar.jar query_maintain_insert.htm
3)jar cvf myjar.jar query_maintain_insert.htm mydirectory
4)jar cv0f myjar.jar query_maintain_insert.htm mydirectory
0---don't want the JAR file to be compressed.
5)jar cmf MANIFEST.MF myjar.jar yahh.txt
m---Used to include manifest information from an existing manifest file.
6)jar cMf MANIFEST.MF myjar.jar yahh.txt
M---the default manifest file should not be produced.
7)jar cvf myjar.jar *
*---create all contents in current directory.
2. 察看jar文件
jar tf jar-file
t---want to view the Table of contents of the JAR file.
eg: 1)jar vft yahh.jar
v---Produces verbose(详细的) output.
3. 提取jar文件
jar xf jar-file [archived-file(s)]
x---want to extract files from the JAR archive.
eg: 1)jar xf yahh.jar yahh.txt(仅提取文件yahh.txt)
2)jar xf yahh.jar alex/yahhalex.txt(仅提取目录alex下的文件yahhalex.txt)
3)jar xf yahh.jar(提取该jar包中的所有文件或目录)
4. 修改Manifest文件
jar cmf manifest-addition jar-file input-file(s)
m---Used to include manifest information from an existing manifest file.
5. 更新jar文件
jar uf jar-file input-file(s)
u---want to update an existing JAR file.