user1757703 user1757703 - 1 month ago 6
Java Question

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

I compiled my old JAR files in Java 7 and my production environment has Java 8. Is there anything I need to be careful about directly deploying the JAR files onto Java 8 Environment? I test ran them on Java 8 and it worked fine. Could I encounter any problems or should I be fine? I was wondering this because I was debating removing Java 8 and installing Java 7.

EDIT: A side question: Do companies update their code when they update their Java version? I can't imagine how painful this must be so have your app working on a previous version and then completely fail on the new version.

Answer

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.)