Java8编译的WAR在Java6环境运行未抛major minor异常,是否正常?
Absolutely, this is a totally normal scenario—here's why:
Your compiled bytecode is likely Java 6 compatible
Even though you used Java 8 to compile the code, you probably configured your build tool (Ant, Maven, Gradle, etc.) to generate Java 6-compatible bytecode. For example, with Ant, you might have set thesourceandtargetattributes to1.6in the<javac>task. TheCreated-Byentry in yourmanifest.mfonly records which JDK was used for compilation—it doesn't dictate the actual bytecode version that the JRE executes.Tomcat 7.0.29 supports Java 6+
Tomcat 7's minimum required JRE is Java 6, so it can happily load and run bytecode targeted at Java 6. The "unsupported major/minor version" error only pops up when the JRE encounters bytecode that was compiled for a newer Java version than it can handle.How to confirm this
You can verify the actual bytecode version of your class files using thejavaptool. Run this command on one of your compiled classes:javap -verbose YourClass | grep "major version"If the output shows
major version: 50, that means the bytecode is Java 6 compatible (Java 6 = 50, Java 8 = 52). This is the real determinant of whether the JRE can run the code, not the manifest entry.
内容的提问来源于stack exchange,提问作者Soham Banerjee

