Evaluating Snippets

In this section, you will evaluate Java expressions using the Java scrapbook. The scrapbook can be used to experiment with Java code fragments before putting them into your program.

1.

In the Java perspective, click the Create a Scrapbook Page button in the workbench toolbar.

2.

In Enter or select the folder field, type or browse below to select the JUnit project root directory ( JUnit ).

3.

In the File name field, type MyScrap. The JPAGE file extension will be added automatically, if you do not enter it yourself.

Click Finish when you are done.

4.

The scrapbook page opens in an editor in the editor area.

5.

In the editor, type System.get and then use content assist (Ctrl+Space) to complete the snippet as System.getProperties().

6.

Select the entire line you just typed and select Display from its context menu to evaluate the expression.

7.

The result of the evaluation is highlighted in the scrapbook page.

8.

Save and close the snippet file by clicking the Close button in the view toolbar and then selecting Yes in the Save dialog.