摸索了半天,总算摸索出头绪出来了.
关键点:
1,hibernate.cfg.xml 要放在 jar中
2,配置MANIFAST.MF,设置好Manifest-Version,Main-Class,Class-Path.
Manifest-Version:
1.0
Main-Class: MyProject.MyEntryClass
Class-Path: ./hibernate/ant-
1.6.5
.jar
./hibernate/ant-antlr-
1.6.5
.jar ./hibernate/ant-junit-
1.6.5
.jar
./hibernate/ant-launcher-
1.6.5
.jar ./hibernate/ant-swing-
1.6.5
.jar
./hibernate/antlr-
2.7
.5H3.jar ./hibernate/asm-attrs.jar
./hibernate/asm.jar ./hibernate/c3p0-
0.9.0
.jar
./hibernate/cglib-
2.1.2
.jar ./hibernate/cleanimports.jar
./hibernate/commons-collections-
2.1.1
.jar
./hibernate/commons-logging-
1.0.4
.jar
./hibernate/concurrent-
1.3.2
.jar ./hibernate/connector.jar
./hibernate/dom4j-
1.6.1
.jar ./hibernate/ehcache-
1.1
.jar
./hibernate/hibernate-tools.jar ./hibernate/hibernate3.jar
./hibernate/jaas.jar ./hibernate/jacc-1_
0
-fr.jar
./hibernate/jaxen-
1.1
-beta-
7
.jar ./hibernate/jboss-cache.jar
./hibernate/jboss-common.jar ./hibernate/jboss-jmx.jar
./hibernate/jboss-system.jar ./hibernate/jdbc2_0-stdext.jar
./hibernate/jgroups-
2.2.7
.jar ./hibernate/jta.jar
./hibernate/junit-
3.8.1
.jar ./hibernate/log4j-
1.2.11
.jar
./hibernate/oscache-
2.1
.jar ./hibernate/proxool-
0.8.3
.jar
./hibernate/swarmcache-
1
.0rc2.jar ./hibernate/versioncheck.jar
./hibernate/xerces-
2.6.2
.jar ./hibernate/xml-apis.jar
注意:
(1)冒号和后面的值中间一定要有一个空格!!!
(2)Class-Path不能太长,否则会报错.如果包实在太多的话,可以换行写.换行时注意新的一行前面要有一个空格!!!
(3)最后一行必须要有一个回车换行!!!!比如上例中如果没最后一个空行,系统会不认Class-Path配置.
3,最好用的工具就是winrar,不要用eclipse export to jar来打包,很不好用.用winrar把文件夹压缩成zip格式,文件后缀改成.jar就成了合法的jar文件,又方便又快捷.
4,小技巧:如果包很多,手写MANIFEST文件很麻烦吧.可以通过cmd进入lib目录,dir,把包名copy到文本文件中.要善于用windows控制台的鼠标拉框copy,每个文件名前那个空格最好也选上,然后批量再替换为需要的目录路径.:P