In this section, you will evaluate Java expressions using the Java scrapbook.
Java scrapbook pages allow you to experiment with Java code fragments before
putting them in your program.
Creating a Java scrapbook page
- In the File menu select New > Other > Java >
Java Run/Debug > Scrapbook Page. You will be prompted for a folder
destination for the page.
- In the Enter or select the folder field, type or browse below
to select the JUnit project root directory.
- In the File name field, type MyScrap.
Click Finish when you are done. A scrapbook page
resource is created for you with the jpage file extension. (The jpage
file extension will be added automatically if you do not enter it yourself.)
The scrapbook page opens automatically in an editor.
- In the editor, type
System.get and then use content assist (Ctrl+Space)
to complete the snippet as
- Select the entire line you just typed and select Display
from the context menu. You can also select Display Result of
Evaluating Selected Text from the toolbar.
- When the evaluation completes, the result of the evaluation is displayed
in the scrapbook page.
- You can inspect the result of an evaluation by selecting text and
choosing Inspect from the context menu (or selecting Inspect
Result of Evaluating Selected Text from the toolbar.)
- When you are finished evaluating code snippets in the scrapbook page, you
can close the editor. Save the changes in the page if you want to keep
the snippets for future use.
Displaying the result of evaluating an expression
Inspecting the result of evaluating an expression
New Java Scrapbook Page wizard
Java scrapbook page