what's the difference between -source and -target compatibility?

前端 未结 3 1850
臣服心动
臣服心动 2020-12-08 03:55

When using the Java compiler (javac), we can specify two kinds of compatibility. One is using -source and the other is using -target.

3条回答
  •  無奈伤痛
    2020-12-08 04:52

    The -source indicates what level of compliance your source code has: are you using Annotations? Then you would need at least 1.5; are you using @override on interface implementations, you would need 1.6 etc

    The -target specifies what Java version you want to be able to run your classes on. You could use a Java SE 7 compiler and compile to run on Java SE 1.5.

提交回复
热议问题