How to convert JAR FILE to COD file using Ant Build

坚强是说给别人听的谎言 提交于 2019-12-24 09:58:29

问题


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>

Error i got was

[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 ...

BUILD FAILED E:\RakeshBBWorkspace\Helios3.6WorkSpace\Code\build.xml:15: Java returned: -1

I tried using this,it shows I/o error.How can it be done?

Regards

Rakesh Shankar.P


回答1:


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.

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.

My full answer is here: BlackBerry: create COD from JAR source file in Ant script

I have also included a summary below - but there are more details in the link.


Only use rapc for the last step - converting that JAR file into a COD.

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.

Steps:

  1. javac the SDK to create CLASS files
  2. preverify the CLASS files
  3. jar the SDK
  4. Copy the SDK JAR file into the project
  5. javac the project - use the SDK JAR as the classpath
  6. preverify the project CLASS files (again, use the SDK JAR in the classpath)
  7. jar the project - add the SDK JAR as a zipfileset
  8. jarjar this project JAR to refactor package names as required
  9. Finally, run rapc on this JAR - it will find no duplicate COD files & should run fine.


来源:https://stackoverflow.com/questions/5241872/how-to-convert-jar-file-to-cod-file-using-ant-build

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!