`

eclipse 之 scrapbook

阅读更多
eclipse 之 scrapbook

      在日常的编码过程中,经常会遇到一些还不确定功能或性能的方法或者代码片段,如果需要测试这段代码,一般需要单独写一个class类来验证,最近在网上不经意间看到一个可以单独运行代码片段的小工具,使用起来挺方便,故摘录下来,以备参考:

      Using Scrapbook Pages
At 6:28 PM on Jan 8, 2006, João Almeida Javalobby Newcomers wrote:

One of the most undervalued and forgotten features of Eclipse is the scrapbook page , which allows to execute Java expressions without having to create a new Java program. This is a neat way to quickly test an existing class or evaluate a code snippet.

To create a scrapbook page choose File -> New -> Other -> Java -> Java Run/Debug -> Scrapbook Page , choose a name and destination folder and that's it. Now there's an empty page where regular Java expressions can be written and evaluated, to do so just select the expression and choose one of the available operations (either in the toolbar now available or the context menu).

Try this: write new java.util.Date() , select the text and click Display or Inspect .

Display will evaluate the expression and print the result directly on the scrapbook, basically the return of a toString() applied to that object or the return value of the selected Java method.

If the information displayed is not enough, there's the Inspect feature (see below) which shows an debug window with all the details of the selected object, and all this happens without executing any code or switching to the Debug perspective.

To evaluate code snippets there's the Execute feature, this will execute a block of code, just like in a regular java program. A quick way to try this is to send something to the standard output: just write System.out.println("Scrapbook example") , select the text and hit Run , this should print something on the Console window (see below).

Because it's created within a Java project a scrapbook page , all the classpath libraries and projects references can be used here; another nice feature is having code assist, just like in a regular Java editor page. In a scrapbook page the class names fully qualified, there's no, this isn't much of a problem because the code completion handles this nicely, but if you're working with unusually large class names you can check the Set Imports option, this will open new window where all the import expressions can be inserted (just the import section of a regular class file).

A scrapbook page is not as fully featured as the Java editor, there's no outline and the code assist is somehow limited, but is not meant to be like that; the idea is working with just a few lines, and this where the scrapbook page can be useful: to quickly test Java expressions and code blocks present in a project in this kind of sandbox.

参考地址:http://www.eclipsezone.com/eclipse/forums/t61137.html
分享到:
评论

相关推荐

    Eclipse中文使用教程

    4 .5 Java 实时运算簿页面 (Java Scrapbook Page ) 4 .6自订开发环境 4 .7产生 getter 与 setter 4 .8建立 JAR 档案 4 .9.建立 Javadoc 文件 4 .10 工作集 (Working Sets ) 5 .除错 5 .1错误的程序 5 .2设定岔断点 ...

    Eclipse – 整合开发工具

    156 4.5 Java即時運算簿頁面(Java Scrapbook Page) 159 4.6自訂開發環境... 166 4.6.1程式碼格式... 166 4.6.2程式碼產生模板... 168 4.6.3 Javadoc註解... 170 4.7產生 getter 與 ...

    Eclipse中文教程.pdf

    Eclipse – 整合开发工具(基础篇) Jacky Lee 2005/03/01 教程特点: 1、图文并茂的详细介绍了eclipse的使用方法 2、虽然是pdf,但是非影音版,所有相当清晰 3、含文档结构目录,可以方便的跳转到对应章节 4、允许...

    eclipse 中文版教程

    45 Java 实时运算簿页面(Java Scrapbook Page) 160 46 自订开发环境 167 461 程序代码格式 167 462 程序代码产生模板 169 463 Javadoc 批注 171 47 产生 getter 与 setter 176 48 建立 JAR 档案 177 481 建立...

    Eclipse从入门到精通.rar

    4.5 Java 实时运算簿页面(Java Scrapbook Page)..... 160 4.6 自订开发环境......... 167 4.6.1 程序代码格式... 167 4.6.2 程序代码产生模板....................... 169 4.6.3 Javadoc 批注... 171 4.7 产生 ...

    Eclipse中文教程文档

    4.5 Java即時運算簿頁面(Java Scrapbook Page) 159 4.6自訂開發環境 166 4.6.1程式碼格式 166 4.6.2程式碼產生模板 168 4.6.3 Javadoc註解 170 4.7產生 getter 與 setter 。175 4.8建立 JAR 檔案 176 4.8.1建立新的 ...

    Eclipse整合开发工具-基础篇

    4.5 Java即時運算簿頁面(Java Scrapbook Page) 159 4.6自訂開發環境 166 4.6.1程式碼格式 166 4.6.2程式碼產生模板 168 4.6.3 Javadoc註解 170 4.7產生 getter 與 setter 。175 4.8建立 JAR 檔案 176 4.8.1建立新的 ...

    Eclipse 中文教程

    4.5 Java实时运算簿页面(Java Scrapbook Page) 115 4.6自订开发环境 122 4.6.1程序代码格式 122 4.6.2程序代码产生模板 123 4.6.3 Javadoc批注 125 4.7产生 getter 与 setter 129 4.8建立 JAR 档案 131 4.8.1建立新...

    Eclipse中文教程

    Eclipse中文教程三册全集 0.环境说明 .................................................................... 8 1.Eclipse 简介................................................................. 9 1.1 历史背景...

    Commonplaces - your digital scrapbook library-crx插件

    您的数字平凡的剪贴簿在这里可以组织所有这些有趣的文章:newspaper:,锻炼视频:woman_in_lotus_position:,利基研究:person:‍ holiday,假Eclipse谱:shallow_pan_of_food:……实际上是任何东西。 通过照片,GIF,...

Global site tag (gtag.js) - Google Analytics