Search code examples
javajavadocdeprecatedjava-6

Deprecate in Java 1.6


In Java 1.5, to deprecate a method you would:

@Deprecated int foo(int bar) {
}

Compiling this in Java 1.6 results in the following:

Syntax error, annotations are only available if source level is 1.5

Any ideas?


Solution

  • You have to tell the compiler to use 1.6:

    javac -source 1.6
    

    Or equivalent for your IDE/build system (as others have suggested).