Josh
Josh

Reputation: 1356

Eclipse @Deprecated yields syntax error

This seems like a simple question that I cannot find the answer to when googling.

The @Deprecated tag is giving me a syntax error in eclipse.

Error:

Deprecated cannot be resolved to a type

Am I missing an import or something?

Edit: Using Eclipse Juno

Upvotes: 1

Views: 799

Answers (3)

A4L
A4L

Reputation: 17595

Here is how to reproduce this error:

  1. Create a project with as run time jdk5 or higher.
  2. Right click on that project and go to Build Path > Configure Build Path...
  3. Go to the Libraries tab, remove the actual JRE System Library (1.5 or higher) and then add JRE System Library 1.4 or lower. Click OK.

The project will rebuild and you'll get the error Deprecated cannot be resolved to a type

So you need to ckeck the setting under the Libraries tab and make sure you have a run time 1.5 or higher.

Upvotes: 1

Josh
Josh

Reputation: 1356

I have solved the problem. Thank you to those who tried to help with comments.

The standard java library (JRE System Library) in the Java Build Path was incorrect.

I corrected this and the syntax error disappears.

Upvotes: 1

rolfl
rolfl

Reputation: 17707

YUou also need to make sure your compiler settings are configured to allow these 'new' features. Project->Properties and go to the Java Compiler section

Project Settings

Upvotes: 2

Related Questions