Is there any Python-like interactive console for Java?

JavaConsole

Java Problem Overview


I spent a lot of time programming in Java recently, and one thing I miss from scripting languages was the ability to test them in a console.

To quickly test a java program, I have to edit a file, then turn it to bytecode and execute it. Even using an IDE, it loses its fun after the 372 th time.

I would like to know if there is a product out there that features anything like an interactive console (I bet you need a JIT compiler) and some autocompletion (with relexivity, I suppose it's possible).

Maybe that's something very common that I just don't know about or something completely impossible, but its worst asking :-)

Java Solutions


Solution 1 - Java

Yes; jshell, and before that some close approximations are Groovy, Clojure, Scala, and the Bean Shell.

Solution 2 - Java

Funnily enough, you get an interactive console with Jython ! You don't get much more Python-like.

Solution 3 - Java

Solution 4 - Java

Try http://drjava.org">Dr Java's "Interaction Pane".

Solution 5 - Java

JShell is now standard in Java 9. JShell introduction

Solution 6 - Java

An approach that I have used to some degree of success is to debug in Eclipse and use the display view. What the display view gives you is the ability to manipulate the code currently running in the JVM through executing Java statements. Any object available at the particular break point you are stopped at is in scope within the display view. While this isn't exactly what you are looking for it does provide some of the features that a REPL provides for other programming environments. See [Debugging with the Eclipse Platform][1] for more information.

[1]: http://www.ibm.com/developerworks/library/os-ecbug/ "Debugging with the Eclipse Platform"

Solution 7 - Java

You can execute Scala interactive interpreter too.

Solution 8 - Java

You may be interested in Groovy.

Solution 9 - Java

You can use BeanShell to run arbitrary Java code. If you want Eclipse integration, EclipseShell has BeanShell support.

Solution 10 - Java

Jgrasp IDE have a interactive console where you can test in, i use it a lot, and there is alos a debug view showing variabel etc efter you have deklare them.

It is opensoruce and you can get a copy att http://www.jgrasp.org/

// Anders

Solution 11 - Java

I've occasionally run into the same problem and have a partial solution. I keep around a file (as Charlie Martin said, Java needs its class contexts) that is little more than a test program. In a second window - a console - I have a script that I run that just checks the modification time of the source file every second or two. When it sees the source change, it re-compiles it (I'm usually fiddling in C, but I've done this with Java, as well) and executes the result.

It's not a great solution, but its a fast one-off and I've found it to be very useful.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questione-satisView Question on Stackoverflow
Solution 1 - JavaCharlie MartinView Answer on Stackoverflow
Solution 2 - JavaBrian AgnewView Answer on Stackoverflow
Solution 3 - JavaDavid PortabellaView Answer on Stackoverflow
Solution 4 - JavaHarryView Answer on Stackoverflow
Solution 5 - Javauser2144406View Answer on Stackoverflow
Solution 6 - JavalazView Answer on Stackoverflow
Solution 7 - JavastepanchegView Answer on Stackoverflow
Solution 8 - JavaPatrick McDanielView Answer on Stackoverflow
Solution 9 - Javaneu242View Answer on Stackoverflow
Solution 10 - JavaAndersView Answer on Stackoverflow
Solution 11 - JavaSniggerfardimungusView Answer on Stackoverflow