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
Java-REPL by Albert Latacz works well.
You can try it directly from your browser here: http://www.javarepl.com/term.html
The source code is available here, and it has a decent Intelli-J plugin.
https://github.com/albertlatacz/java-repl
you can script java using jruby http://kenai.com/projects/jruby/pages/CallingJavaFromJRuby
Clojure provides a REPL you can use.
The groovy console allows you to do that. It actually was meant to try and test groovy code, but since groovy is a superset of Java, it allows plain Java stuff as well.
I just entered this into the console:
InetAddress.getAllByName('localhost')
and hit CTRL-R, then it returned:
groovy> InetAddress.getAllByName('localhost')
Result: [localhost/127.0.0.1]
If you already know Groovy (which I assume you do, since you mentioned the Groovy Console), then just use groovysh or groovyConsole, which are included in the Groovy distro. If you have custom jars that you want to import, you can either write a batch file that starts up groovysh/groovyConsole with those added to the classpath. You can also do this
this.class.classLoader.rootLoader.addURL(new URL("file:///path to file"))
from within the shell to load other jars.
I used to use Jython several years ago to do just what you're asking. As part of my build script, I generated a custom jython.bat and .py file that included the full classpath for the project I was working on. That way when I started Jython, it would have all the code available, and it would bring up Spring to let me twiddle things in the live system. You can do the same thing with Groovy, JRuby, BeanShell, etc.
Java 9 is providing the JShell.
jshell> println( "Print me!")
jshell> Print me!