M Siddique
M Siddique

Reputation: 1019

The import javax.annotation.Resource cannot be resolved

I have tried to resolve by adding missing/unnecessary jar's but nothing works for me. if you know how to resolve this issue then kindly help... Thank you in advance.

Code IDE ERROR

I am using JDK 9.0.4 installed in this IDE Eclipse 4.7 Oxygen December 2017

Windows 10

Servlet 4.0

JSP 2.3

JSTL tags

Upvotes: 12

Views: 21691

Answers (4)

y4h2
y4h2

Reputation: 3383

If you're using maven managing your dependencies, you can also add the below dependency in your pom.xml.

<dependency>
    <groupId>javax.annotation</groupId>
    <artifactId>javax.annotation-api</artifactId>
    <version>1.3.2</version>
</dependency>

OR download the jar file from here https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api/1.3.2

Upvotes: 2

Lukas R
Lukas R

Reputation: 11

Or go to : right click your project->build path->configure build path->add external JARs->"C:\Program Files\Apache Software Foundation\Tomcat 9.0\lib\annotations-api.jar" and all will be right.

Upvotes: 1

Evan-Gao
Evan-Gao

Reputation: 141

I have encountered the same problem with you.
Download javax.annotation.jar online and add to your library may help.

Upvotes: 3

M Siddique
M Siddique

Reputation: 1019

Eclipse is facing some bugs in IDE 4.7 it is not fully compitable with JDK 9 like in with JDK 9 IDE is not generating toString() function also...

so i change the JDK 9 to jdk 8.1 and it solves all the problem.

to change the JDK...

Window > Preferences > Installed JREs >>> Change the JDK 9 to JDK xx

AND/OR

Right Click Project > Properties > JRE > Edit >>> YOUR ALTERNATIVE JDK xx

This had solved my problem.

Upvotes: 11

Related Questions