blob: 58e411ee2cf7f38414747e3c0f1f588b17633a5b [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css">
<title> Evaluating snippets </title>
</head>
<body>
<h1> Evaluating snippets </h1>
<p> 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. </p>
<ol>
<li> In the File menu select <STRONG>New &gt; Other &gt; Java &gt;
Java Run/Debug &gt; Scrapbook Page</STRONG>. You will be prompted for a folder
destination for the page. <p> <img src="../images/org.eclipse.jdt.debug.ui/jpage_wizard.png" alt="Create Java Scrapbook Page wizard">
</p></li>
<li> In the <strong>Enter or select the folder</strong> field, type or browse below
to select the <em>JUnit</em> project root directory. </li>
<li> In the <strong>File name</strong> field, type <em>MyScrap</em>.&nbsp; </li>
<li>
Click <strong>Finish</strong> when you are done.&nbsp; A scrapbook page
resource is created for you with the <em>jpage</em> file extension.&nbsp; (The <em>jpage
</em>file extension will be added automatically if you do not enter it yourself.)&nbsp;
The scrapbook page opens automatically in an editor.
<p> <img src="../images/org.eclipse.jdt.debug.ui/empty_jpage.png" alt="Package Explorer and editor area of the active perspective">
</p>
</li>
<li> In the editor, type <code>System.get</code> and then use content assist (Ctrl+Space)
to complete the snippet as <code>System.getProperties()</code>.
<p> <img src="../images/org.eclipse.jdt.debug.ui/scrap_assist.png" alt="Content proposals popup"> </p>
</li>
<li> Select the entire line you just typed and select <strong>Display</strong>
from the context menu.&nbsp; You can also select <strong>Display Result of
Evaluating Selected Text</strong> from the toolbar.
<p> <img src="../images/org.eclipse.jdt.debug.ui/scrap_display.png" alt="Snippet editor with System.getProperties() selected showing context menu">
</p>
</li>
<li> When the evaluation completes, the result of the evaluation is displayed
and highlighted
in the scrapbook page. </li>
<li> You can inspect the result of an evaluation by selecting text and
choosing <strong>Inspect</strong> from the context menu (or selecting <strong>Inspect
Result of Evaluating Selected Text</strong> from the toolbar.) </li>
<li> When you are finished evaluating code snippets in the scrapbook page, you
can close the editor.&nbsp; Save the changes in the page if you want to keep
the snippets for future use. </li>
</ol>
<p><img border="0" src="../images/ngrelc.png" alt="Related concepts" ><br>
<a href="../concepts/concepts-10.htm">Debugger</a></p>
<p><img border="0" src="../images/ngrelt.png" alt="Related tasks" ><br>
<a href="../tasks/tasks-149.htm">Creating a Java scrapbook page</a><br>
<a href="../tasks/tasks-151.htm">Displaying the result of evaluating an
expression</a><br>
<a href="../tasks/tasks-150.htm">Inspecting the result of evaluating an
expression</a><br>
<a href="../tasks/tasks-107.htm">Viewing compilation errors and warnings</a></p>
<p><img border="0" src="../images/ngrelr.png" alt="Related reference" ><br>
<a href="../reference/ref-129.htm">New Java Scrapbook Page wizard</a><br>
<a href="../reference/ref-34.htm">Java scrapbook page</a><br>
<a href="../reference/ref-56.htm">Expressions view</a></p>
<p><a href="../notices.html"><img src="../cpy.png" border="0" alt="Legal notices" ></a>
</p>
</body>
</html>