In general, no.
Backward compatibility means that you can run a program in Java 7 during the execution of Java 8, and not vice versa.
There are several reasons for this:
Bytecode is versioned, and the JVM checks to see if it supports the version found in .class files.
Some language constructs cannot be expressed in previous versions of bytecode.
The new JRE has new classes and methods that will not work with the old ones.
If you really want to really (hint: you wonβt do this), you can force the compiler to view the source code as one version of Java and emit bytecode for another using something like this:
javac -source 1.8 -target 1.7 MyClass.java
( same for Maven ) and compile with JDK7, but in practice it will work more often than work. I do not recommend doing this.
EDIT : JDK 8 does not seem to support this exact combination, so this will not work. Some other version combinations work.
There are also programs for converting newer Java programs to work with older JVMs. To convert Java 8 to 5-7 you can try https://github.com/orfjackal/retrolambda . To get below 5, you can choose one of them: 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, threads, time APIs, unsigned APIs, etc. Therefore, I would say that it is not worth it.
Or, since you want to run Java 8 JEE applications on the application server, just run your entire Java 8 server, it might work.
Karol S Mar 24 '14 at 13:12 2014-03-24 13:12
source share