Adding annotations using the Annotations view.

You can add annotations in your source code by using the Annotations view.

Before you begin

In the Java™ EE perspective, if the Annotations view does not appear in the bottom of the workspace, you need to add the Annotations view. For more information, see Using the Annotations view.

Procedure

  1. In the Enterprise Explorer view, double-click your Java class to open the file in the Java editor.
  2. Click the Annotations view tab.
  3. Select the Java element that you want to add an annotation to.
  4. Click Add annotation.
    Add annotation
  5. In the Add annotation page, select the annotation that you want to add:
    Add Annotation dialog
  6. To filter the annotations, type a letter or term into the type filter text field. You can use "*", "?", or camel case:
    Add Annotation filter
  7. Select the annotation you want to insert into your Java class, and click OK
  8. You see in the Java class the @Stateless annotation is added to your code.
  9. When you press CTRL+S to save, you can see a quick fix icon quick fix icon beside the @Stateless line
  10. Right-click the quick fix icon and select Quick Fix:
  11. Select Import 'Stateless' (javax.ejb) and press CTRL+S to save:
    Add Import 'Stateless' (javax.ejb)
  12. You see in the Java class that your annotation is added to the code. Highlight the annotation, and the details for this annotation appear in the Annotation view.
    Add parameters to annotation
  13. The attributes pane shows both the default values (which you can change) and assigned values.

Feedback