Chinaunix首页 | 论坛 | 博客
  • 博客访问: 45679
  • 博文数量: 22
  • 博客积分: 536
  • 博客等级: 中士
  • 技术积分: 205
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-11 00:59
文章分类

全部博文(22)

文章存档

2013年(1)

2012年(5)

2011年(16)

我的朋友
最近访客

分类: Java

2011-06-14 04:57:08

Create jar file
jar c[v0M]f jarfile [-C dir] inputfiles [-Joption]
jar c
[v0]mf manifest jarfile [-C dir] inputfiles [-Joption] [-e entrypoint]
jar c
[v0M] [-C dir] inputfiles [-Joption]
jar c[v0]m manifest [-C dir] inputfiles [-Joption]

Update jar file
jar u[v0M]f jarfile [-C dir] inputfiles [-Joption]
jar u[v0]mf manifest jarfile [-C dir] inputfiles [-Joption] [-e entrypoint]
jar u
[v0M] [-C dir] inputfiles [-Joption]
jar u[v0]m manifest [-C dir] inputfiles [-Joption]

where:
entrypoint

The name of the class that set as the application entry point for stand-alone applications bundled into executable jar file. The -e option and entrypoint are a pair -- if either is present, they must both appear. The letters m, f and e must appear in the same order that manifest, jarfile, entrypoint appear.

Temporarily changes directories to dir while processing the following inputfiles argument. Multiple -C dir inputfiles sets are allowed.


OPTIONS

e
Sets as the application entry point for stand-alone applications bundled into executable jar file. The use of this option creates or overrides the Main-Class attribute value in the manifest file. This option can be used during creation of jar file or while updating the jar file. This option specifies the application entry point without editing or creating the manifest file.

For example, this command creates Main.jar where the Main-Class attribute value in the manifest is set to Main:
jar cfe Main.jar Main Main.class

The java runtime can directly invoke this application by running the following command:

java -jar Main.jar
If the entrypoint class name is in a package it may use either a dot (".") or slash ("/") character as the delimiter. For example, if Main.class is in a package called foo the entry point can be specified in the following ways:
jar -cfe Main.jar foo/Main foo/Main.class
or
jar -cfe Main.jar foo.Main foo/Main.class
Note:  specifying both -m and -e options together when the given manifest also contains the Main-Class attribute results in an ambigous Main.class specification, leading to an error and the jar creation or update operation is aborted.


-C
 dir
Temporarily changes directories (cd dir) during execution of the jar command while processing the following inputfiles argument. Its operation is intended to be similar to the -C option of the UNIX tar utility. For example:
jar uf foo.jar -C classes bar.class
changes to the classes directory and add the bar.class from that directory to foo.jar. The following command,
jar uf foo.jar -C classes . -C bin xyz.class (我的注:-C dir file(s) -C dir file(s)
changes to the classes directory and adds to foo.jar all files within the classes directory (without creating a classes directory in the jar file), then changes back to the original directory before changing to the bin directory to add xyz.class to foo.jar. If classes holds files bar1 and bar2, then here's what the jar file contains using jar tf foo.jar:
META-INF/
META-INF/MANIFEST.MF
bar1
bar2
xyz.class

 
来源:

阅读(1370) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~