在Java 7中编译的加载/运行类6 [英] Loading/Running classes compiled in java 7 in java 6

查看:115
本文介绍了在Java 7中编译的加载/运行类6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用一些客户端jars在我的组件客户端jars编译和运行与java 7.我不能移动到java 7由于一些管理决策。我想客户端jar工作(编译/运行)在我的java 6任何方式我可以实现这个?



感谢

解决方案

我想让客户端jars在我的java 6工作(编译/运行)我可以实现这个?


如果您有源代码,可以尝试在Java 6构建平台上编译代码。但是,没有保证它将编译和运行原样:




  • 代码可能使用Java 7语言结构。 / p>


  • 代码可能使用Java 7特定类或方法。




坏消息是,没有魔法的方式来处理从上面产生的任何编译错误。你需要将Java 7-isms手动翻译成Java 6兼容的源代码。



但是好消息是如果代码在Java 6 JDK上编译,很有可能它将在Java 6 JRE上运行。






没有权限访问该源代码,那么问题就更加困难了。



理论上可以将字节码翻译成早期版本,但是这样做的工具往往有显着的局限性。以下是一些可能的潜在客户:





请注意,我没有找到一个复古到Java 6.(没有人做过工作,或者有一些关于Java 7使问题难以解决。)


I am using some client jars in my component the client jars are compiled and run with java 7.I am not able to move to java 7 due to some management decisions .I want the client jars to work (compile/run) in my java 6 any way i can achieve this?

Thanks

解决方案

I want the client jars to work (compile/run) in my java 6 any way i can achieve this?

If you have source code, you can try compiling the code on a Java 6 build platform. However, there are no guarantees it will compile and run as-is:

  • The code may use Java 7 language constructs.

  • The code may use Java 7 specific classes or methods.

The bad news is that there is no magic way to deal with any compilation errors arising from the above. You will need to hand translate the Java 7-isms into Java 6 compatible source code.

But the good news is that if the code does compile on Java 6 JDK, there is pretty good chance that it will run on Java 6 JRE.


If you don't have access to that source code, then the problem is much, much harder

It is theoretically possible to translate bytecode to an earlier version, but the tools for doing this are tend to have significant limitations. Here are some possible leads:

Note that I've not managed to find a "retro" tool that translates Java 7 to Java 6. (Either nobody has done the work, or there is something about Java 7 makes the problem intractable.)

这篇关于在Java 7中编译的加载/运行类6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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