Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a Java 8 codebase be compiled and work on a Java 6 VM?

Tags:

java

java-8

Will a Java 8 codebase that is compiled with Java 8 work on a Java 6 VM?

like image 674
Renaud Avatar asked Mar 21 '26 18:03

Renaud


1 Answers

Yes, but if you don't make use of features of java 7 and java 8 ...

If the codebase is written using features of newer java versions, then no there's no way to do it!

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
like image 90
aleroot Avatar answered Mar 23 '26 09:03

aleroot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!