3

In scripting languages like Ruby/Python/Perl, we can start an interactive session and create new variables, and essentially execute whatever statements.

But in Java, I only know of a way to print arbitrary expressions - in Eclipse's debug-expression view.

There is no way to create new vars, and later utilize that var (though you can assign to pre-existing vars).

Is there any way to run Java in a interpreted IDE environment just like scripting languages?

rene
42.6k78 gold badges122 silver badges166 bronze badges
asked Aug 3, 2012 at 22:19

3 Answers 3

5

Check out Groovy. If you want to stick to pure Java, I think Groovy will happily execute any valid Java code. You can poke at it via the GroovySH interactive shell.

answered Aug 3, 2012 at 22:27
Sign up to request clarification or add additional context in comments.

Comments

3

Check out Beanshell It has been around a while. Also you can look at IDEOne website for an online IDE-like environment for several languages (not quite a shell). And yeah, I meant to mention Groovy too, which has the groovy shell.

answered Aug 3, 2012 at 22:26

Comments

0

As of Java 9 there will be a REPL available to allow you to start an interactive Java session.

It's called JShell, and you can read the original proposal: JEP 222: jshell: The Java Shell (Read-Eval-Print Loop)

There are a number of blogs and articles exploring some of the features of JShell, if you'd like to see it in action.

answered May 2, 2017 at 6:53

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.