In general, no.
Backward compatibility means you can run Java 7 program on Java 8 runtime, not vice versa).
There are several reasons for this:
-
The bytecode has the version and JVM checks if it supports the version it finds in the .class files.
-
Some language constructs cannot be expressed in previous versions of bytecode.
-
There are new classes and methods in the new JREs that don’t work with the older ones.
If you really want to (hint: don’t), you can force the compiler to treat the source as one version of Java and output bytecode for another, using something like this:
javac -source 1.8 -target 1.7 MyClass.Java
( the same for Maven ), and compiling against JDK7, but in practice more often than not it will not work than work. I advise you not to do this.
[~ # ~] edit [~ # ~] : JDK 8 apparently doesn’t support this exact combination, so it won’t work. Some other version combinations work.
There are also programs to convert the new Java to work on older JVMs. For Java 8 to 5-7 conversion, you can try https: //github.com/orfjackal/retrolambda To get a value below 5, you can choose one of these: http://en.wikipedia.org/wiki/Java_backporting_tools
None of these hacks will give you new Java 8 classes and methods, including functional programming support for collections, streams, time APIs, unsigned APIs, and so on. So I’d say it’s not worth it.
Or, since you want to run Java 8 JEE applications on one application server, run the entire server on Java 8, it might work.