Dan Barowy
Dan Barowy

Reputation: 2270

How can I obtain an interactive shell (like Ruby's irb) for Java?

I spent the last year doing Ruby development, and during that time I discovered irb, which makes running little "code experiments" easy and fun. I've recently switched teams and am now doing Java development, and I've found that I really miss my irb window. I would like to do the same thing for Java, but I don't know how.

I'm using Eclipse (groan), but Eclipse's bells and whistles are not the same thing.

Upvotes: 17

Views: 5088

Answers (5)

Robina Li
Robina Li

Reputation: 1298

Tried JShell and beanshell. Do suggest JShell over beanshell. Up key will roll back to history lines. Display much user friendly.

Thank you @Anders Sandvig

It can be found in jdk since java 9.

Upvotes: 0

Anders Sandvig
Anders Sandvig

Reputation: 20986

Old question, I know, but jshell: The Java Shell (Read-Eval-Print Loop), is coming in Java 9 (Summer 2017, hopefully).

Upvotes: 5

Austin Taylor
Austin Taylor

Reputation: 5477

BeanShell is probably what you're looking for.

https://github.com/beanshell/beanshell

Upvotes: 22

Robin
Robin

Reputation: 24262

Would "Use an Eclipse Java Scrapbook page" be better ;-)

I haven't actually used irb, but if you just want to run code snippets inside of eclipse, then this is a simple way of doing it.

Upvotes: 4

ataylor
ataylor

Reputation: 66069

There are a few choices: BeanShell has been around for a long time, and is a great Java REPL.

Another alternative is groovy's groovysh or groovyConsole. While groovy isn't Java in the strict sense, it's great for interactively playing around with Java classes.

Upvotes: 6

Related Questions