随笔 - 154  文章 - 60  trackbacks - 0
<2007年11月>
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678

声明:

该blog是为了收集资料,认识朋友,学习、提高技术,所以本blog的内容除非声明,否则一律为转载!!

感谢那些公开自己技术成果的高人们!!!

支持开源,尊重他人的劳动!!

常用链接

留言簿(3)

随笔分类(148)

随笔档案(143)

收藏夹(2)

其他

学习(技术)

观察思考(非技术)

搜索

  •  

最新评论

阅读排行榜

评论排行榜

好久没玩这个了!复习一下! 
D盘根目录下写  Test.java
 

public class Test{
    
public static void main(String[] args){
        System.out.println(
"*******--TEST  JAVA!--*********");
    }

}

javac Test.java

试一下 java Test           OK!

jar cvf  test1.jar Test.class,回车后去D盘,OK多了 test1.jar 
jar cvf   jar文件名  mf 文件名   .class文件     

第二种玩法 做一个*.mf文件内容如下:
 
Manifest-Version: 1.0
Created-By: 1.6.0-beta2 (Sun Microsystems Inc.)
Main-Class: Test

可以根据第一种方法生成的 MANIFEST.MF  改

将*.mf 和.class放在一个目录中

jar cvfm h.jar 11.mf  Test.class
jar cvfm   jar文件名  mf 文件名   .class文件     


执行
java -jar hello.jar    
java -jar jar文件全名

package  com.lk.test打包

jar cvfm hh.jar test.mf com

package  com.lk.test打包+配置文件

jar cvfm hh.jar test.mf com db.properties

就可以将db.properties放在和com并列的目录下


如果使用了第三方jar包 : 要写入.mf文件中

Manifest-Version: 1.0
Main-Class: lk.Test
Class-Path: lib/jxl.jar

另外在写manifest.mf 文件的时候也有两点务必注意
Main-Class: test.test        Class: test.test 之间的一个空格,另外,行尾务必回车换行


===========jar帮助================

用法: jar {ctxui}[vfm0Me] [jar-file] [manifest-file] [entry-point] [-C dir] files ...
选项包括:
    -c  创建新的归档文件
    -t  列出归档目录
    -x  解压缩已归档的指定(或所有)文件
    -u  更新现有的归档文件
    -v  在标准输出中生成详细输出
    -f  指定归档文件名
    -m  包含指定清单文件中的清单信息
    -e  为捆绑到可执行 jar 文件的独立应用程序指定应用程序入口点

    -0  仅存储;不使用任何 ZIP 压缩
    -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基本操作:

############

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.
eg: 1)jar cf myjar.jar query_maintain_insert.htm
2)jar cvf myjar.jar query_maintain_insert.htm
v---Produces verbose(详细的) output.
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.
posted on 2007-11-06 15:22 lk 阅读(343) 评论(0)  编辑  收藏 所属分类: j2se

只有注册用户登录后才能发表评论。


网站导航: