我在创建 jar 时遇到问题。详情如下:
[amulay@pugthesestock-dr Desktop]$ ll src/com/foo/bar/
-rw-rw-r-- 1 amulay amulay 421 Jul 17 11:40 Test1.class
-rw-rw-r-- 1 amulay amulay 125 Jul 17 11:40 Test1.java
-rw-rw-r-- 1 amulay amulay 421 Jul 17 11:40 Test2.class
-rw-rw-r-- 1 amulay amulay 125 Jul 17 11:39 Test2.java
[amulay@pugthesestock-dr Desktop]$ jar -cvf Test.jar -C src src/com/foo/bar/*.class
src/src/com/foo/bar/Test1.class : no such file or directory
added manifest
adding: com/foo/bar/Test2.class(in = 421) (out= 288)(deflated 31%)
[amulay@pugthesestock-dr Desktop]$ unzip -l Test.jar
Archive: Test.jar
Length Date Time Name
--------- ---------- ----- ----
0 07-17-2013 11:47 META-INF/
68 07-17-2013 11:47 META-INF/MANIFEST.MF
421 07-17-2013 11:40 com/foo/bar/Test2.class
--------- -------
489 3 files
文件 Test2.class 已添加到 jar 中,但未添加到 Test1.class 中?
最佳答案
在开始压缩文件之前,-C
选项将更改为给定文件夹。
应该是:
jar -cvf Test.jar -C src com/foo/bar/*.class
创建一个“可运行”的jar。
关于java - jar -C 命令的奇怪行为 : not all expected files included,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17692503/