1

Does the Java compiler work well if using a target level lower than the source level? For example:

javac -source 1.7 -target 1.6
Jacob
  • 77,566
  • 24
  • 149
  • 228
Jeremy Wang
  • 1,495
  • 3
  • 13
  • 19

1 Answers1

-2

if you compiler code use java 1.7,the code can not run with java 1.6,if you do this,you will receive a Unsupported major.minor version.

Pan
  • 97
  • 3
  • Err, yes it can, if it compiles and you use the -target 1.6 switch, which is what the question is about. – user207421 Oct 14 '16 at 06:11
  • 1
    I've just tried for modern source level 1.8 with bytecode target version 1.7 but it failed: **[javac] javac: source release 1.8 requires target release 1.8** – Splash Aug 04 '20 at 10:06
  • @Splash Any idea why that happens? I thought that it should be possible to set the target lower than the source level, but apparently that's not the case. Can't find any good reference. – Safron Oct 05 '22 at 13:29
  • Maybe they are too lazy to implement all new features of Java 8 using old 7 version internal mechanic. – Splash Mar 06 '23 at 15:38