Interactive Java code execution?

Hello,

is there a functionality to execute Java code interactively in IDEA like the "Java scrapbook" in Eclipse?
This is sometimes very usefull to test little code snippets.

Thanks in advance,
Helge

6 comments
Comment actions Permalink

Hi Helge,

There is no exact analogue at IJ.

The closest feature is 'evaluate expression/code fragment' during debugging.

Alternatively, you can create simple groovy script and do what you want there using java syntax.

Regards, Denis

0
Comment actions Permalink

There is also a BeanShell plugin maybe that is what you are searching.
BeanShell is a scripting dialect of Java.
Almost all valid Java 5 code is also valid in BeanShell.

0
Comment actions Permalink

A Groovy script is a little to heavy for me because I don't want to install/setup Groovy just to evaluate a small Java snippet like

"abc\\def".replaceAll("\\\\", "\\\\\\\\");

0
Comment actions Permalink

Then I still think the BeanShell plugin could be what you are after if it is done correctly.
The BeanShell integration into jEdit and possibly the Console plugin would be exactly what you need.

0
Comment actions Permalink

I'll try this tomorrow at work.

Helge

0
Comment actions Permalink

bewalticus wrote:

A Groovy script is a little to heavy for me because I don't want to install/setup Groovy just to evaluate a small Java snippet like

"abc\\def".replaceAll("\\\\", "\\\\\\\\");

I'm afraid complexity of that operation is slightly overstated - download groovy binaries and setup their location at jetgroovy plugin doesn't look too heavy :)

Denis

0

Please sign in to leave a comment.