问题描述
我有一个 JAR 文件,我想知道如何将 JAR 文件转换为 COD 文件.
I have a JAR File,i want to know how to convert the JAR file to COD file.
<target name = "build-MyLib" depends="clean">
<rapc destdir="release\5.0" output="Lib">
<src>
<fileset dir=".">
<include name="lib/Lib.jar" />
</fileset>
</src>
</rapc>
</target>
我得到的错误是
[rapc] java.util.zip.ZipException: duplicate entry: Lib-1.cod
[rapc] at java.util.zip.ZipOutputStream.putNextEntry(Unknown Source)
[rapc] at java.util.jar.JarOutputStream.putNextEntry(Unknown Source)
[rapc] at sun.tools.jar.Main.addFile(Unknown Source)
[rapc] at sun.tools.jar.Main.create(Unknown Source)
[rapc] at sun.tools.jar.Main.run(Unknown Source)
[rapc] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[rapc] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[rapc] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[rapc] at java.lang.reflect.Method.invoke(Unknown Source)
[rapc] at net.rim.tools.compiler.c.e.if(Unknown Source)
[rapc] at net.rim.tools.compiler.c.e.a(Unknown Source)
[rapc] at net.rim.tools.compiler.Compiler.a(Unknown Source)
[rapc] at net.rim.tools.compiler.Compiler.a(Unknown Source)
[rapc] at net.rim.tools.compiler.Compiler.compile(Unknown Source)
[rapc] at net.rim.tools.compiler.Compiler.main(Unknown Source)
[rapc] I/O Error: jar command failed: jar -cfm E:\RakeshBBWorkspace\Helios3.6WorkSpace\Code\release\5.0\Lib.jar C:\DOCUME~1\rakesh\LOCALS ...
构建失败E:\RakeshBBWorkspace\Helios3.6WorkSpace\Code\build.xml:15:Java 返回:-1
BUILD FAILEDE:\RakeshBBWorkspace\Helios3.6WorkSpace\Code\build.xml:15: Java returned: -1
我试过用这个,显示I/O错误,怎么办?
I tried using this,it shows I/o error.How can it be done?
问候
Rakesh Shankar.P
Rakesh Shankar.P
推荐答案
我也遇到了这个问题,并就同一主题发布了一个问题.经过这里的一些答案并进一步研究后,我找到了答案.
I also had this problem, and posted a question on the same topic. After some answers from here, and further research, I have figured out the answer.
基本上,您需要使用普通的 java 工具构建初始 JAR 文件,而不是使用 rapc
.最后一步只使用 rapc
.这样,您的 JAR 文件将不包含任何中间 COD 文件.
Basically, you need to build the initial JAR file using normal java tools, rather than using rapc
. Only use rapc
for the final step. That way, your JAR file will not contain any intermediate COD files.
我的完整答案在这里:黑莓:从 Ant 脚本中的 JAR 源文件创建 COD
我还在下面包含了一个摘要 - 但链接中有更多详细信息.
I have also included a summary below - but there are more details in the link.
仅在最后一步使用 rapc
- 将该 JAR 文件转换为 COD.
Only use rapc
for the last step - converting that JAR file into a COD.
处理这个问题的完整 ANT 构建框架太大了,无法放在这里,但下面列出了创建它所需的步骤.每个步骤都可以在此站点上轻松研究(或使用一些谷歌).每一步都非常简单,可以单独调试.
A full ANT build framework to deal with this problem is too big to place here, but the steps needed to create it are listed below. Each of the steps can be easily researched on this site (or with some google). Each step is very simple, and can be debugged individually.
步骤:
javac
用于创建 CLASS 文件的 SDK预验证
CLASS 文件jar
SDK- 将 SDK JAR 文件复制到项目中
javac
项目 - 使用 SDK JAR 作为 classpathpreverify
项目 CLASS 文件(再次使用 classpath 中的 SDK JAR)jar
项目 - 添加 SDK JAR 作为 zipfilesetjarjar
这个项目的 JAR 根据需要重构包名- 最后,在这个 JAR 上运行
rapc
- 它不会发现重复的 COD 文件 &应该运行良好.
javac
the SDK to create CLASS filespreverify
the CLASS filesjar
the SDK- Copy the SDK JAR file into the project
javac
the project - use the SDK JAR as the classpathpreverify
the project CLASS files (again, use the SDK JAR in the classpath)jar
the project - add the SDK JAR as a zipfilesetjarjar
this project JAR to refactor package names as required- Finally, run
rapc
on this JAR - it will find no duplicate COD files & should run fine.
这篇关于如何使用 Ant Build 将 JAR 文件转换为 COD 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!