Java:是否有工具使代码(在第三方JAR中)向前兼容(1.4 - 1.6) [英] Java : Is there a tool to make code (in a 3rd party JAR) forward compatible (1.4 - 1.6)

查看:97
本文介绍了Java:是否有工具使代码(在第三方JAR中)向前兼容(1.4 - 1.6)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Java 1.4编译的第三方JAR文件。有没有一个工具可以使jar文件与Java 1.6兼容? (类似'逆向转换器',但它的反转是什么)。

我尝试反编译类文件并在1.6中重新编译但它失败了。

I have a 3rd party JAR file that is compiled using Java 1.4. Is there a tool that can make the jar file compatible with Java 1.6? (Something like 'retrotranslator' but what does the reverse of it).
I tried decompiling the class files and re compile them in 1.6 but it fails.

以下是问题:


我的项目使用'rsadapter.jar'为5.1,我在Eclipse 2.0 +中进行了项目设置JDK 1.4以及以前的工作正常。现在,我已经迁移到Java 1.6和Eclipse Ganymede(根据要求),同一个项目(完全相同的设置)开始抱怨'rsadapter.jar'中缺少的类文件。我也明确地将JAR放在classpath中,但它仍然无法加载类。然后我将Java Compiler版本更改为1.4并开始工作。

Here is the issue:

My project uses 'rsadapter.jar' for was 5.1 and I had my project setup in Eclipse 2.0 + JDK 1.4 and it used to work fine. Now, I have migrated to Java 1.6 and Eclipse Ganymede (as per the requirements) and the same project (exactly same setup) started complaining about the missing class files in the 'rsadapter.jar'. I put the JAR in classpath explicitly too but it still could not load the classes. Then I changed the Java Compiler version to 1.4 and it started working.

问候,

- Ashish

Regards,
- Ashish

推荐答案

JDK 1.4编译的类应该可以在Java 6运行时中使用。如果您确实遇到了问题,请说明一下。

Classes compiled by JDK 1.4 should be usable in a Java 6 runtime as-is. If you have actually encountered a problem, please describe it.

更新:我只能使用默认包中的类型(即不在包中)重现此类。您尝试在默认包中使用的类是什么?此外,无论用于编译的JDK版本如何,这都会发生在我身上。

Update: I can only reproduce this with types in the "default" package (that is, not in a package). Are the classes you are trying to use in the default package? Also, this happens to me regardless of the JDK version used to compile.

更新:好的,经过一些研究,我意识到你永远不能从命名包中引用未命名包中的类型。有道理,但绝对不是你遇到的。

Update: Okay, after a little research, I realized that you can never reference a type in the unnamed package from a named package. Makes sense, but definitely not what you are running into.

我可以在JDK 1.4.2_19下编译代码并在Java 6 Eclipse项目中很好地利用它。我认为这个问题是您的环境特有的。在这种情况下,我会备份Eclipse并从头开始重新创建所有内容(JDK安装,工作区,项目),看看是否可以清除它。

I can compile code under JDK 1.4.2_19 and utilize it just fine in a Java 6 Eclipse project. I think that this problem is something specific to your environment. In this situation, I would backup Eclipse and recreate everything (JDK installation, workspace, projects) from scratch, to see if I could clear it up.

这篇关于Java:是否有工具使代码(在第三方JAR中)向前兼容(1.4 - 1.6)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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