On this page:
- Enabling annotations in the project
- Enabling annotations in Gradle or Maven projects
- Enabling annotations using editor
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
To enable annotations, follow these steps:
- Open the Project Structure dialog (e.g. Ctrl+Shift+Alt+S).
- In the Project Structure dialog box, click Libraries.
- Click . Select Library Files dialog box opens.
- Under <IntelliJ IDEA home> directory, select
redist/annotation-java8.jar, and click OK:
- 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
To enable annotations in Gradle or Maven projects, follow these steps:
- 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 or
org.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
To enable annotations in the editor:
- In the editor, write
@NotNulland press Alt+Enter:
The selected JAR file is added:
Note that if a project is imported from the Maven model, IntelliJ IDEA will add the dependency to the