| <!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 > Other > Java > |
| Java Run/Debug > 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>. </li> |
| <li> |
| |
| Click <strong>Finish</strong> when you are done. A scrapbook page |
| resource is created for you with the <em>jpage</em> file extension. (The <em>jpage |
| </em>file extension will be added automatically if you do not enter it yourself.) |
| 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. 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. 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> |
| |