Opening a Java editor

In this section, you will learn how to open an editor for Java files. You will also learn about some of the basic Java editor features.

  1. Expand the package junit.samples and select the file You can open in the Java editor by double clicking on it. In general you can open a Java editor for Java files, types, methods and fields by simply double clicking on them. For example, to open the editor directly on the method testClone defined in, expand the file in the Package Explorer and double click on the method.
  2. Notice the syntax highlighting. Different kinds of elements in the Java source are rendered in unique colors.  Examples of Java source elements that are rendered differently are:

    Syntax highlighting

  3. Look at the Outline view. It displays an outline of the Java file including the package declaration, import declarations, fields, types and methods. The Outline view uses icons to annotate Java elements.  For example, icons indicate whether a Java element is static (S), abstract (A), or final (F).  Different icons show you whether a method overrides a method from a base class (overridden ) or when it implements a method from an interface (implements ).

    Outline view

  4. Toggle the Hide Fields, Hide Static Members, and Hide Non-Public Members buttons in the Outline view toolbar to filter the view's display. Before going to the next step make sure that the Hide Non-Public Members and Hide Static Fields and Methods buttons are not pressed.

    Outline view tool bar

  5. In the Outline view, select different elements and note that they are again displayed in a whole file view in the editor. The Outline view selection now contains a range indicator on the vertical ruler on the left border of the Java editor that indicates the range of the selected element.

    Range indicator

Java views
Java editor
Sorting elements in Java views Java Outline View
Java Editor Preferences