构建可移植的JAR-一罐classnotfound异常

时间:2018-11-17 18:08:05

标签: java jar onejar

任何帮助或指导都将不胜感激-将我的头发拉出来!

http://one-jar.sourceforge.net/index.php?page=getting-started&file=quickstart

尝试执行命令行方法

1)下载了one-jar-boot-0.97.jar

2)创建了一个名为“ root”的目录

3)两个子目录; lib和main

4)将相关的JAR文件复制到lib

5)将我的程序jar“ rackserials.jar”复制到main     -这个罐子(工作)的清单很简单     “主类:tdms.rackserials”

6)解压缩one-jar-boot-0.97.jar
    jar -xvf one-jar-appgen-0.97.jar

-这是开始偏离URL的地方

-“删除src树”-卸载列表中没有这样的文件!

-no boot-manifest.mf

-文件是:com; doc; META-INF; one-jar- $ project $ .jar; OneJar.class

7)META-INF \ MANIFEST.MF是

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: One-Jar 0.97 Ant taskdef
One-Jar-Main-Class: com.simontuffs.onejar.appgen.AppGen
Main-Class: com.simontuffs.onejar.Boot

8)将上述清单复制到\ root \ boot-manifest.mf并修改为

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: One-Jar 0.97 Ant taskdef
One-Jar-Main-Class: main.tdms.rackserials
Main-Class: com.simontuffs.onejar.Boot

9)创建了新的jar

jar -cvfm ../one-jar.jar boot-manifest.mf .
added manifest
adding: .DS_Store(in = 6148) (out= 471)(deflated 92%)
adding: one-jar-appgen-0.97.jar(in = 312610) (out= 310633)(deflated 0%)
ignoring entry META-INF/
ignoring entry META-INF/MANIFEST.MF
adding: boot-manifest.mf(in = 175) (out= 131)(deflated 25%)
adding: one-jar-$project$.jar(in = 268270) (out= 266489)(deflated 0%)
adding: .version(in = 23) (out= 25)(deflated -8%)
adding: lib/(in = 0) (out= 0)(stored 0%)
adding: lib/xmlbeans-3.0.1.jar(in = 2582300) (out= 2203838)(deflated 14%)
adding: lib/poi-ooxml-schemas-4.0.0.jar(in = 6477408) (out= 5094564)(deflated 21%)
adding: lib/json-20180813.jar(in = 64597) (out= 61529)(deflated 4%)
adding: lib/commons-collections4-4.2.jar(in = 752798) (out= 665931)(deflated 11%)
adding: lib/poi-ooxml-4.0.0.jar(in = 1758061) (out= 1639592)(deflated 6%)
adding: lib/json-simple-1.1.1.jar(in = 23737) (out= 20832)(deflated 12%)
adding: lib/poi-4.0.0.jar(in = 2715721) (out= 2482096)(deflated 8%)
adding: lib/commons-compress-1.18.jar(in = 591748) (out= 529487)(deflated 10%)
adding: doc/(in = 0) (out= 0)(stored 0%)
adding: doc/one-jar-license.txt(in = 1781) (out= 911)(deflated 48%)
adding: main/(in = 0) (out= 0)(stored 0%)
adding: main/main.jar(in = 7010) (out= 5590)(deflated 20%)
adding: main/rackserials.jar(in = 33941) (out= 33586)(deflated 1%)
adding: com/(in = 0) (out= 0)(stored 0%)
adding: com/simontuffs/(in = 0) (out= 0)(stored 0%)
adding: com/simontuffs/onejar/(in = 0) (out= 0)(stored 0%)
adding: com/simontuffs/onejar/OneJarFile$2.class(in = 1298) (out= 725)(deflated 44%)
adding: com/simontuffs/onejar/JarClassLoader$2.class(in = 848) (out= 460)(deflated 45%)
adding: com/simontuffs/onejar/JarClassLoader$FileURLFactory$1.class(in = 1072) (out= 509)(deflated 52%)
adding: com/simontuffs/onejar/Boot$1.class(in = 1700) (out= 921)(deflated 45%)
adding: com/simontuffs/onejar/Boot$3.class(in = 1398) (out= 736)(deflated 47%)
adding: com/simontuffs/onejar/JarClassLoader$IURLFactory.class(in = 430) (out= 251)(deflated 41%)
adding: com/simontuffs/onejar/OneJarFile.class(in = 3529) (out= 1759)(deflated 50%)
adding: com/simontuffs/onejar/IProperties.class(in = 280) (out= 203)(deflated 27%)
adding: com/simontuffs/onejar/JarClassLoader.class(in = 29043) (out= 14084)(deflated 51%)
adding: com/simontuffs/onejar/OneJarURLConnection.class(in = 1638) (out= 809)(deflated 50%)
adding: com/simontuffs/onejar/JarClassLoader$FileURLFactory.class(in = 2320) (out= 1056)(deflated 54%)
adding: com/simontuffs/onejar/Boot$2.class(in = 1905) (out= 961)(deflated 49%)
adding: com/simontuffs/onejar/OneJarFile$1.class(in = 543) (out= 324)(deflated 40%)
adding: com/simontuffs/onejar/JarClassLoader$1.class(in = 2532) (out= 1115)(deflated 55%)
adding: com/simontuffs/onejar/Handler$1.class(in = 1771) (out= 854)(deflated 51%)
adding: com/simontuffs/onejar/JarClassLoader$ByteCode.class(in = 974) (out= 525)(deflated 46%)
adding: com/simontuffs/onejar/Boot.class(in = 17398) (out= 8524)(deflated 51%)
adding: com/simontuffs/onejar/Handler.class(in = 863) (out= 485)(deflated 43%)
adding: com/simontuffs/onejar/JarClassLoader$OneJarURLFactory.class(in = 1414) (out= 711)(deflated 49%)
adding: OneJar.class(in = 1046) (out= 594)(deflated 43%)

10)尝试运行新创建的jar

11)

java -jar one-jar.jar
Exception in thread "main" java.lang.ClassNotFoundException: main.tdms.rackserials
    at com.simontuffs.onejar.JarClassLoader.findClass(JarClassLoader.java:713)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at com.simontuffs.onejar.JarClassLoader.loadClass(JarClassLoader.java:630)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at com.simontuffs.onejar.Boot.run(Boot.java:336)
    at com.simontuffs.onejar.Boot.main(Boot.java:168)

0 个答案:

没有答案