Reputation: 169
I often need to run simple (one/two-line) programs to quickly get the output of a method I'm developing. However, to do so I need to create a new class, add a main method, and write the code there.
I was wondering if there is a simpler way to do this, because I do this quite often.
An example would be:
FormatHelper.format("\\1Does \\2This work?");
I know there needs to be some kind of context for a program to run (classpath, etc.), but I was thinking IntelliJ could handle it for me.
Upvotes: 2
Views: 148
Reputation: 169
There is an IntelliJ IDEA plugin called Java REPL, which implements exactly what I was looking for.
The only downside (if you can call it a downside) is that you have to install a plugin
Upvotes: 0
Reputation: 11453
You should use http://ideone.com/ which is an online IDE.
Just write your one line code and hit run button
Upvotes: 0
Reputation: 48105
You can start the Groovy Shell from the Tools menu and run the expression there. Java expressions will work just fine.
Upvotes: 1
Reputation: 2287
This may not be exactly what you described, but check out this question: 'Immediate' window for IntelliJ
It appears to be related, and indicates that in IntelliJ 9 "There is ALT-F8 to evaluate an expression"
Upvotes: 1
Reputation: 1169
I just often hold a Test Class on a test package and do everything algorithm testing-related inside my main method there.
But to directly answer your question, AFAIK no IDE will do what you want.
On a side note, it may be worth trying ideone or compileonline
Upvotes: 0