Flaw in Java 1.6

In Java 1.5, to abandon the method you:

@Deprecated int foo(int bar) {
}

Compiling this in Java 1.6 leads to the following:

Syntax error, annotations only available if source level 1.5

Any ideas?

+3
source share
9 answers

You should tell the compiler to use 1.6:

javac -source 1.6

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

+9
source

Firstly, its @Deprecated, and secondly, double check if you are really compiling Java 1.6. What are you using? Javac Eclipse?

javac, , JAVA_HOME JDK 6, JDK 1.4.2 Eclipse ( IDE), > a > .

+7

, , 1,5

IDE. 1.4 . , Eclipse ( , Eclipse), Java > 1.5 . Java .

+3

Eclipse IDE,

1- Project Explorer

2 → → Java

3- " "

4- " " "1.6"

. 1.6, 1.5.

5- "".

IDE , . Apply, .

+2

, , , , Eclipse.

, Java ( > > Java > ), , 1.6. , . .

. > a > Java. , , 1,4, , . , , , 1,5 .

.

+2

, 1.5. Java 6 .

? Eclipse, / /JDK?

javac,

javac -version

, .

+1

, Java 1.6, 1.4 ( )? ?

0

@Deprecated @Deprecate

Eclipse, , Java Compiler 1.6.

0

, java 1.6 eclipse. , . Java " ", 1.6, . .

0

Source: https://habr.com/ru/post/1723792/


All Articles