In my machine (Windows 10), there are two versions of Java, Java 1.8 (JRE and JDK) and Java 10 (JRE and JDK).
Previously IF I set my Eclipse to:
- Java Compiler (JDK Complience) : 1.8
- Java Build Path (JRE System Libraries) : 1.8
THEN IF i use following Spring code
import javax.annotation.PostConstruct;
...
...
...
@PostConstruct
...
...
Everything works fine. No error at all.
However, IF I set my Eclipse to:
- Java Compiler (JDK Complience) : 10
- Java Build Path (JRE System Libraries) : 10
Now, the import
statement is throwing an Error message:
The import javax.annotation.PostConstruct cannot be resolved
and this error also happen on @PreDestroy
annotation too.
Why is this happening? What happen to Java 10? How to solve this problem if i still want to retain Java Compiler and JRE System Libraries version to Java 10?
Thank You.
Project > Clean...
Not certain if it will solve your problem but it does with me 99% of the time when Eclipse doesn't find my imports. – Ursal