问题描述
最近我被分配到一项任务,其中我必须将现有的独立 Java 应用程序从 Java 1.6 升级到 Java 1.8.
我还没有完成代码,我对这个项目一无所知.
Recently I was assigned to a task wherein I have to upgrade the existing standalone java application from Java 1.6 to Java 1.8.
I'm yet to go through the code and I have no idea about this project.
他们正在使用蚂蚁 1.6.1,
轴 1.5.1,
ABINITIO 2.15,
甲骨文 11.1.0.7,
AUTOSYS R11,
Java 1.6.
They were usingANT 1.6.1,
AXIS 1.5.1,
ABINITIO 2.15,
ORACLE 11.1.0.7,
AUTOSYS R11,
Java 1.6.
我了解到,首先我需要确定上述工具/框架是否与 Java 1.8 兼容.
I got to know that first I need to identify whether the above mentioned Tools/Frameworks are compatible with Java 1.8.
请建议我在编译和构建应用程序时可能遇到的其他挑战是什么?
Please suggest what are the other challenges I might encounter while compiling and building the application?
推荐答案
虽然 Java 应该在版本之间向后兼容,但众所周知,任何语言的向后兼容性并不像名称所暗示的那样直接.一些(大多数)项目发布了专门针对一个或另一个开发工具包编译的库版本,以利用添加到该语言的新功能和增强功能.
Although Java is supposed to be backward compatible between versions, it's also known that backward compatibility in any language isn't aways as straight forward as the name suggests. Some (most) projects release it's libs versions compiled specifically targeting one or another development kit, to take advantage of new features and enhancements added to the language.
话虽如此,我相信更聪明的方法是:首先,更新项目的 JDK 并针对新的字节码版本重建它.您有可能必须同时升级 Ant 和(如果这是您选择的 IDE)Eclipse(在这里查看原因).
That being said, I believe the smarter way to go would be: first, update the project's JDK and rebuild it targeting the new bytecode's version. There's a chance you'll have to upgrade both Ant and (if that's your IDE of choice) Eclipse (see here why).
其次,您必须检查编译错误,这很可能会导致您有条件地更新库以修复它们.解决这些问题后,您必须运行您的应用程序并查看它是否按预期运行;请记住,当主题是依赖项时,编译问题只是冰山一角.
Second, you'll have to check for compilation errors, which will most likely lead you to update libraries conditionally to get them fixed. With those solved, you MUST run your app and see if it's running as intended; remember that compilation problems are just the top of the iceberg when the subject are dependencies.
仔细检查应用的日志,查找任何类型的异常,但主要是与类加载异常相关的异常,例如 ClassCastException、ClassNotFoundException、NoClassDefFoundException、UnsatisfiedLinkError 等.如有出现,就得一一查明,寻找具体的麻烦制造者库的具体解决方案.
Carefully check the app's logs looking for exceptions of any kind but mainly the ones related to class loading exceptions such as ClassCastException, ClassNotFoundException, NoClassDefFoundException, UnsatisfiedLinkError and others. If any apear, you'll have to pinpoint one by one and search for the specific solution of the specific troublemaker library.
完成所有这些后,您的应用应该会再次正常运行.
With all that covered, you should have your app running healthily again.
最后一个提示,如果您的这个项目仍在开发中,那么最好将您使用的工具更新到它们的最后一个版本.还要更新开发工具,如构建(如 Ant、Maven、Gradle 等)、JDK 和 IDE.在发布时升级这些部分比处理大规模升级要容易得多:)
One last hint, if this project of yours is still being developed, it would be a very good practice to keep the tools you use updated to their very last release. Keep also the development tools updated, like build (such as Ant, Maven, Gradle and others), JDK's and IDE's. It way easier to upgrade the pieces as they are release than to handle a mass scale upgrade :)
这篇关于将现有的 Java 项目从 Java 1.6 升级到 1.8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!