Javac Cross-Compilation with 1.7

前端 未结 2 1745
星月不相逢
星月不相逢 2020-12-31 04:18

So guys,

I\'m trying to play a bit with Javac Cross compilation with Ant and on terminal. Locally and on an integration environment and i\'m having the same problem

2条回答
  •  Happy的楠姐
    2020-12-31 04:46

    You cannot have a newer version of source and lower version of target. For example, In Java 5, a number of new features were added to the language, such as generics, autoboxing and you cannot expect a JVM 1.4 to understand it. So, you must tell the compiler that your source code is Java 1.4 source code. This explains the results you have.

    The default for -target depends on the value of -source:

    • If -source is not specified, the value of -target is 1.7
    • If -source is 1.2, the value of -target is 1.4
    • If -source is 1.3, the value of -target is 1.4
    • If -source is 1.5, the value of -target is 1.7
    • If -source is 1.6, the value of -target is 1.7
    • For all other values of -source, the value of -target is the value of -source.

    For more info refer to http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html

提交回复
热议问题