Is there something like python\'s interactive REPL mode, but for Java?
So that I can, for example, type InetAddress.getAllByName( localHostName )
in a window, a
Beanshell 2
There's an online REPL: http://www.javarepl.com/console.html
Typing more to reach the character limit ...
A REPL called JShell (developed by Oracle) has been released as part of JDK 9.
Just download JDK 9, and launch bin/jshell
.
While JRuby, BeanShell, Julian Fleischer's REPL are there Albert Latacz's REPL seems to be the latest and active.
Tried it with a simple class definition, works fine.
$ java -jar javarepl.jar
Welcome to JavaREPL version 56 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_17)
Type in expression to evaluate.
Type :help for more options.
java> public class Test {
| public static void execute(String [] s) {
| System.out.println(54353 + s[0]);
| }}
java> Test.execute(new String [] {"234343"});
54353234343
java> System.exit(0);
Seems nobody mentioned yet that Java (6, 7) ships a REPL console called jrunscript
. It is language agnostic (so can be used with Jython, JRuby etc.). It defaults to JavaScript (Rhino) which is also bundled by default, and like the other languages you can access all the packages/objects available on the classpath.
DrJava is an educational IDE that includes an REPL pane.
There is an Eclipse plugin as well, but it hasn't worked for me. I think it just hasn't been updated in a while. So what I generally do is keep a DrJava window open for the "what happens if I do this" questions.
EclipseShell might be good too, but I haven't used it yet.