For NetBeans IDE 7.1, there is a community contributed plugin available in the Update Center that adds support for the BeanShell scripting language.
BeanShell (http://www.beanshell.org/) is a small, free, embeddable Java source interpreter with object scripting language features, written in Java. It has been developed by Pat Niemeyer and released as (JSR-274).
The BeanShell plugin for NetBeans integrates seamlessly into the IDE. Within a usual Java SE project, you'll find a new BeanShell script filetype in the "New File" dialog. These files with a .bsh extension contain the scripts. BeanShell scripting uses default Java syntax, so you could write some lines of test code right away. The scripting features of BeanShell script make it quite fun to use and to experiment with.
One really useful feature of the plugin is the interactive scripting console. The fact that BeanShell and Java share the same syntax makes it possible to execute snippets of Java code in the scripting console. This comes in handy if you, e.g., just want to check some small piece of code and don't want to setup a test application or a JUnit test for that. You can find the scripting console window at Window/Other/BeanShell: