Scrapbook in Eclipse
by, 05-24-2011 at 02:23 PM (4720 Views)
Consider the following scenario: you are working on a project with client specific APIs .You need to test some API methods before you put them in your real code. For that, you might consider a separate test workspace or defining a new test class in your running workspace. What about scrapbook page? Ever heard of it?
Eclipse provide scrapbook pages to test write test code for experimental purposes. It is easier to use a Java scrapbook page than create a new class. A scrapbook page might contain random snippets of code that you can execute at any time without a context.
A scrapbook page has extension .jpage. To create a new scrapbook file, simply create a file with a .jpage extension. You can also use the New Scrapbook Page wizard as shown below:
Now you have created the scrapbook page lets write some code in it and see how it works.
Write Java code in scrapbook page. Code assistant is also available. Use it if required. To execute the code, highlight the code, right click it and select execute.
There are three ways to execute your code:
- Execute the selected code and place the returned result in an inspect popup
- Execute the selected code and place the String result right in the scrapbook page
- Execute the selected code (and ignore any returned result)
You can find these actions in the scrapbook page's context menu.
Output:Java Code:System.out.println(new Date());
Java Code:Date cannot be resolved to a typeOutput:Java Code:System.out.println(new java.util.Date());
Java Code:Sun Oct 05 10:23:44 CEST 2008