IntelliJ IDEA lets you enable annotations in projects locally, through Maven repository for projects imported from Gradle or Maven model and through the editor. .
Enabling annotations in the project
- Click
to open the project structure dialog. - In the Project Structure dialog box, click Libraries.
- Under that <IntelliJ IDEA home> directory, select
redist/annotation .jar, and click OK:
- Click
. Select Library Files dialog box opens. - If your project contains more than one module, choose the desired module to be modified, and click OK:

-
The new library is added to the classpath:

Enabling annotations in Gradle or Maven projects
- Click
to open the project structure dialog. - In the Project Structure dialog box, on the Modules page, click the Dependencies tab.
- On the Dependencies tab, click
and from the
list that opens, select Library. - In the Choose Library dialog, click New Library and from the
Select Library Type list, select From Maven.

- In the Download Library From Maven Repository dialog, enter
org.jetbrains:annotations:15.0that contains annotations for Java 8 ororg.jetbrains:annotations-java5:15.0that contains annotations compatible with Java 5 and click OK.
- In the Choose Libraries dialog box, click Add Selected.
The new library is added to the list of dependencies and to the classpath.

Enabling annotations using editor
- In the editor, write
@NotNulland press Alt +Enter to invoke Add 'annotations' to classpath action.
IntelliJ IDEA will automatically choose Java 5 or Java 8 compatible JAR file based on your project's settings
and add the JAR file to the project.

pom.xml.