X

Geertjan's Blog

  • August 20, 2013

Java Scrapbook for NetBeans IDE

Geertjan Wielenga
Product Manager

In a couple of NetBeans discussions and issues, users are asking for a Java scrapbook feature:

http://forums.netbeans.org/ptopic51181.html

https://netbeans.org/bugzilla/show_bug.cgi?id=191488

I took Jesse Glick's Scrapbook feature, mentioned at the end of the issue above, included Java code templates, coloring, and other features, and have made it available as a plugin in the Plugin Portal:

http://plugins.netbeans.org/plugin/50195/?show=true

After you install it in NetBeans IDE 7.3.1 or above, create a new Java project (Java SE, or EE, or whatever, so long as the project has a Java classpath). The feature lets you keep track of sample code snippets, which are stored in a scrapbook file in the 'private' folder of your NetBeans project and when you run them, after right-clicking in the editor, they are executed against the project's classpath.  

So, you first need to create a Java project, since the classpath from the project is used when you run the snippet:

Then the editor opens and you can use quite a few of the Java editing features, but not code completion, to write some snippets:

By default, i.e., if  you select nothing in the editor, when you right-click and choose "Run Snippet" everything in the editor is run. However, if you have something selected, e.g., the whole of line 7 above, then only that line will be run. In other words, you can run blocks of code.

Similar plugins, though they don't let you run code:

http://plugins.netbeans.org/plugin/5811/tabbed-scratchpad

http://plugins.netbeans.org/plugin/5349/scratch-pad

Interested to know how useful this feature is considered to be! Ultimately, maybe something to include in NetBeans IDE? 

Join the discussion

Comments ( 10 )
  • not just any guest Tuesday, August 20, 2013

    Love this feature and have been missing it since the days of the great VisualAge for Java.


  • guest Wednesday, August 21, 2013

    Hi,

    nice plugin. But how to fix this in the Output-Window of the Scrapbook:

    warning: Supported source version 'RELEASE_6' from annotation processor 'org.netbeans.modules.openide.modules.PatchedPublicProcessor' less than -source '1.7'

    warning: Supported source version 'RELEASE_6' from annotation processor 'org.netbeans.modules.openide.util.ServiceProviderProcessor' less than -source '1.7'

    warning: Supported source version 'RELEASE_6' from annotation processor 'org.netbeans.modules.openide.util.NamedServiceProcessor' less than -source '1.7'

    warning: Supported source version 'RELEASE_6' from annotation processor 'org.netbeans.modules.openide.util.NbBundleProcessor' less than -source '1.7'

    Thanks


  • guest Friday, August 23, 2013

    I have been waiting for this for quite some time now :)

    I would love it to have it available in the standard IDE

    Thanks


  • bill Monday, August 26, 2013

    How about including this for php and html ?


  • guest Monday, November 18, 2013

    Hi, Looks pretty cool plugin but I'm getting following warning and unable to use it.

    warning: Supported source version 'RELEASE_6' from annotation processor 'org.netbeans.modules.openide.modules.PatchedPublicProcessor' less than -source '1.7'

    warning: Supported source version 'RELEASE_6' from annotation processor 'org.netbeans.modules.openide.util.ServiceProviderProcessor' less than -source '1.7'

    warning: Supported source version 'RELEASE_6' from annotation processor 'org.netbeans.modules.openide.util.NamedServiceProcessor' less than -source '1.7'

    warning: Supported source version 'RELEASE_6' from annotation processor 'org.netbeans.modules.openide.util.NbBundleProcessor' less than -source '1.7'


  • Jesse Glick Saturday, November 23, 2013

    Ah yes, the supported source version idiocy. Maybe you can get my https://bugs.openjdk.java.net/browse/JDK-7184902 reopened. :-)


  • Nux Wednesday, June 18, 2014

    Yes, would be cool if you could update for Netbeans 8 (Java 1.8). Maybe just rename "_.java" to "scrapbook.java" and that would work?


  • Emerson Thursday, March 12, 2015

    Great! It works on Netbeans 8.0.2 without errors for me.

    Thanks for this plugin!


  • Emerson Thursday, March 12, 2015

    A feature request: context menu for gradle projects. For now I'm using a dummy netbeans default project to be able to open the scrapbook.


  • guest Wednesday, November 18, 2015

    This plugin does not work in 8.1 - Would appreciate if this is fixed.


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.