backwards compatibility - A program made with Java 8 can be run on Java 7? -


i little confused.

  1. oracle says java 8 highly compatible java 7 (backward). but, possibilities exist java 8 program can run on java 7 (se/ee)?

  2. if point 1 true, java 8 applications deployed , executed on java 7 server support? example, tomcat 8 or wildfly?

in general, no.

the backwards compatibility means can run java 7 program on java 8 runtime, not other way around.

there several reasons that:

  • bytecode versioned , jvm checks if supports version finds in .class files.

  • some language constructs cannot expressed in previous versions of bytecode.

  • there new classes , methods in newer jre's won't work older ones.

if really, want (tip: don't), can force compiler treat source 1 version of java , emit bytecode another, using this:

javac -source 1.8 -target 1.7 myclass.java 

(the same maven), , compile against jdk7, in practice more not work work. i recommend don't.

edit: jdk 8 apparently doesn't support exact combination, won't work. other combinations of versions work.

there programs convert newer java programs work on older jvm's. converting java 8 5-7, can try https://github.com/orfjackal/retrolambda lower 5, can pick 1 of these: http://en.wikipedia.org/wiki/java_backporting_tools

none of these hacks give new java 8 classes , methods, including functional programming support collections, streams, time api, unsigned api, , on. i'd it's not worth it.

or, since want run java 8 jee applications on application server, run entire server on java 8, may work.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -