Search code examples
antcompiler-errorsjavac

javac Error use -source 5 or higher to enable generics


I'm getting this weird errors, when trying to build vuze via ant:

[javac] /home/jalil/src/azureus-4.3.0.6/com/aelitis/azureus/core/impl/AzureusCoreImpl.java:1087: for-each loops are not supported in -source 1.4
[javac] (use -source 5 or higher to enable for-each loops)
[javac]         for (Object l : runningListeners) {
[javac]                       ^
[javac] /home/jalil/src/azureus-4.3.0.6/com/aelitis/azureus/core/instancemanager/impl/AZInstanceImpl.java:41: generics are not supported in -source 1.4
[javac] (use -source 5 or higher to enable generics)
[javac]         Map<String,Object>      map )
[javac]            ^
[javac] 100 errors

BUILD FAILED

/home/jalil/src/azureus-4.3.0.6/build.xml:39: Compile failed; see the compiler error output for details.

Solution

  • Your compiler expects code that conforms to an older java version than 1.5. Foreach loops and generics are features that were only added in Java 1.5, which is why the compiler rejects that code. You also got a pretty explicit error message explaining the problem and how to solve it.

    You need to edit the command line you pass to javac (probably by editing the ant files) to make sure it expects Java 1.5 or newer input, by providing -source 1.5 (or 1.6 or 1.7, etc.) or its synonym, -source 5 (or 6 or 7, etc.). You can also try removing any -source option altogether, the default is probably newer than the 1.5 you need.