Search code examples
javabackwards-compatibilityforward-compatibility

Can newer versions of java run on older versions?


I have a doubt as to whether java is backward compatible or forward compatible? Also, can we run java bytecode written in JDK 11 Windows on a MAC which has JDK 8 without any complications? I'm trying to understand the concept of platform independence.


Solution

  • Short answer: Yes. That’s the point. Your ancient byte code, even from Java 1, will run under Java 11.

    More detailed answer: There have been a few classes that have now finally actually been deleted from the standard library. But chances are that you did not use them.

    Edit: I seem to have misread your question. No, you cannot run code compiled with Java 11 under Java 8. The bytecode version has been increased, and Java 8 will refuse to run it.