Bug 191488 - Interactive Java expression evaluator attached to project
Interactive Java expression evaluator attached to project
Status: NEW
Product: java
Classification: Unclassified
Component: Project
All All
: P3 with 11 votes (vote)
Assigned To: Tomas Zezula
Depends on:
  Show dependency treegraph
Reported: 2010-10-30 18:17 UTC by DeepFrz
Modified: 2013-11-22 23:12 UTC (History)
6 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description DeepFrz 2010-10-30 18:17:22 UTC
I have searched the web and have found several people asking about a Scrapbook feature (as in Eclipse Scrapbook) but could not find that a feature request has been filed. 

The scrapbook is a page that can be attached to a project in the IDE and can be used to evaluate or test run java code. A very handy feature indeed.
Comment 1 Jesse Glick 2010-11-01 14:27:00 UTC
The Evaluate window that appears when debugging the project is similar, though the UI is clumsy for writing complex expressions, and they are not persisted. This is also not available without starting the app, whereas e.g. with jrunscript you can interactively check various functions so long as they require no special services to be running.

This feature could surely be implemented as an add-on plugin. I am not sure what the best way to parse and evaluate Java code interactively is; you probably need to use JSR 199 to actually compile a block somehow, as if it formed a method body.
Comment 2 Martin Entlicher 2010-11-02 21:16:39 UTC
I haven't tried Eclipse' Scrapbook, but I do not think this has anything to do with debugger.

IMHO it can be implemented either by compiling the user-written code in a dedicated class and running that, or by interpreting the code (in a similar way that is done by debugger, but instead of delegating the execution through debugger, run it in a special class loader).

IMHO this is about execution, not debugging.
Perhaps it would be nice if one can also debug the code snippet, but the main concept needs to be implemented in Java project, I think.
Comment 3 DeepFrz 2010-11-03 01:43:14 UTC

The above link is to a download page for a beginner's tutorial on java and Eclipse. The tutorial on the Scrapbook is in lesson #3, unfortunately all lessons must be downloaded in order to watch it. I think the Scrapbook feature would make a very nice enhancement to Netbeans. Very handy for evaluating code snippets without having to build an entire class or even a method. Perhaps more valuable to a beginner (again) like me than to an experienced developer.

I would encourage anyone who is interested in this feature to download and watch lesson #3 of the above tutorial.
Comment 4 snailgem 2010-11-17 22:24:13 UTC
here is the help page from eclipse for this feature:

and here is another useful link:

what is not clear from these links, though, is that this is not only an expression evaluator. if you attach a scrapbook page to an eclipse project, you can run things related to the classes in that project from the scrapbook: instantiate an object, call its methods, call a main method etc.

it would be terrific to have something this useful in eclipse!
Comment 5 snailgem 2010-11-17 22:31:34 UTC
(erratum to comment #4)

> it would be terrific to have something this useful in *netbeans*!
Comment 6 MrRemedy 2012-05-26 03:02:48 UTC
Having this feature is the current time saver tool holding me back from totally switching to Net beans IDE.

More votes please.
Comment 7 Jesse Glick 2012-05-29 23:27:10 UTC
(In reply to comment #2)
> compiling the user-written code in a dedicated class and running that

That is fine and probably not too hard; requires nothing specifically from the project system, just a ClassPath[] context from GlobalPathRegistry (EXECUTE).

The hard part would be displaying the object inspector on results as the Eclipse scrapbook does. Of course this is not absolutely necessary - you could just display the toString() of each result - but a key feature. In NB this GUI currently exists only in the debugger and is not available for reuse.
Comment 8 Jesse Glick 2012-05-30 23:29:29 UTC
I committed contrib #ce13cee71654 with a very rudimentary scrapbook feature - no Java syntax highlighting or code completion, run blocks only (no expression evaluation or mixing imports with statements), no object inspector, no support for alternate boot classpaths, etc. But it does work to keep track of some sample code snippets and run them against the project's classpath (use println(...) to display results).
Comment 9 markiewb 2013-11-22 23:12:47 UTC
FYI: Geertjan took jglicks code and created a proof-of-concept plugin out of it


Perhaps this could be improved and integrated?

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo