如何使用Ant生成JAR文件转换为COD文件 [英] How to convert JAR FILE to COD file using Ant Build

查看:260
本文介绍了如何使用Ant生成JAR文件转换为COD文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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 FAILED E:\RakeshBBWorkspace\Helios3.6WorkSpace\Code\build.xml:15: Java returned: -1

我试着用这一点,它显示了I / O error.How能不能做到?

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

问候

拉​​克什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

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.

仅使用 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.

步骤


  1. 的javac 的SDK创建CLASS文件

  2. preverify 的类文件

  3. JAR 的SDK

  4. 的SDK JAR文件复制到项目

  5. 的javac 项目 - 使用SDK JAR作为的的classpath

  6. preverify Project类文件(再次,请使用SDK JAR中的的classpath 的)

  7. JAR 项目 - 添加SDK JAR作为的 zipfileset

  8. jarjar 这个项目JAR重构包名的要求

  9. 最后,运行 RAPC 这个JAR - 它会发现没有重复的COD文件和放大器;应该运行正常。

  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.

这篇关于如何使用Ant生成JAR文件转换为COD文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆