Java SE 8: Would a Java 7 compiled JAR be compatible completely with Java 8?

萝らか妹 提交于 2019-12-02 04:40:36

I was wondering this because I was debating removing Java 8 and installing Java 7.

I assume you mean the other way around?

Java attempts to maintain backwards compatibility as far as it can, so theoretically at least you should be ok.

In practice however, issues do sometimes come up, so I'd advocate testing thoroughly. These may be due to regression bugs, or (more likely in my experience) buggy code that might have run fine under Java 7, but not under 8. (FWIW, I had a couple of FX apps that mixbehaved under 8 but ran fine under 7, it turned out both were due to bugs in my code that coincidentally had no unusual side effects when running with 7.)

Usually, there should be no problem. Otherwise you would have a hard time to use any third-party libraries not explicitly compiled for Java SE 8.

I recommend to run your automated tests on a continuous integration server such as Jenkins using Java SE 8 and see if you have any issues.

It is safe to package Java 8 application with jar dependencies compiled with Java 7. Given that said, however, keep in mind differences in JDK 7 and 8, that can result the same Java code could behave differently when running on JDK 8 vs JDK 7 (refer to JDK 8 release notes)

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