可以在Java 6 VM上编译Java 8代码库并在其上工作吗?
使用Java 8编译的Java 8代码库是否可以在Java 6 VM上工作?
Will a Java 8 codebase that is compiled with Java 8 work on a Java 6 VM?
是的,但是如果您不使用Java 7和Java 8的功能...
Yes, but if you don't make use of features of java 7 and java 8 ...
如果代码库是使用较新的Java版本的功能编写的,则 否没办法!
If the codebase is written using features of newer java versions, then no there's no way to do it!
但是,如果要在Java 6上运行它们,则必须在编译源代码文件时设置Java 6合规性级别(使用-source 1.6 -target 1.6
javac参数),以使其与Java 6兼容.如上所示设置合规性,您将得到一个 UnsupportedClassVersionError :
However, if you want to run them on java 6 you have to set java 6 compliance level(with -source 1.6 -target 1.6
javac parameters) when you compile source code files, to make them compatible with java 6. If you don't set the compliance as shown above, you will get an UnsupportedClassVersionError :
java.lang.UnsupportedClassVersionError:Unsupported major.minor version XX.X