IntelliJ IDEA 2017.1 Help

Enabling Annotations

On this page:


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:

  1. Open the Project Structure dialog (e.g. Ctrl+Shift+Alt+S).
  2. In the Project Structure dialog box, click Libraries.
  3. Click /help/img/idea/2017.1/new.png. Select Library Files dialog box opens.
  4. Under <IntelliJ IDEA home> directory, select redist/annotation.jar/ redist/annotation-java8.jar, and click OK:
  5. If your project contains more than one module, choose the desired module to be modified, and click OK:
  6. 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:

  1. Click /help/img/idea/2017.1/projectStructure.png to open the project structure dialog.
  2. In the Project Structure dialog box, on the Modules page, click the Dependencies tab.
  3. On the Dependencies tab, click /help/img/idea/2017.1/new.png and from the list that opens, select Library.
  4. In the Choose Library dialog, click New Library and from the Select Library Type list, select From Maven.
  5. In the Download Library From Maven Repository dialog, enter org.jetbrains:annotations:15.0 that contains annotations for Java 8 or org.jetbrains:annotations-java5:15.0 that contains annotations compatible with Java 5 and click OK.
  6. 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 @NotNull and 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 pom.xml.

See Also

Last modified: 18 July 2017