Is there any Python-like interactive console for Java?

Recently, I spent a lot of time programming in Java, and one thing I missed in scripting languages ​​is the ability to test them on the console.

To quickly test a java program, I have to edit the file and then translate it into bytecode and execute it. Even using the IDE, he loses pleasure after the 372nd time.

I would like to know if there is a product there that has something like an interactive console (I suppose you need a JIT compiler) and some autocompletion (with reusability, I suppose it is possible).

Perhaps something is very common that I just don’t know or something is completely impossible, but its worst is asking :-)

+61
java console
Apr 24 '09 at 19:50
source share
10 answers

Not really, because Java is not clearly defined without a class structure and so on. But some close approximations are in Groovy , Clojure , Scala , and Bean Shell .

+34
Apr 24 '09 at 19:54
source share
+12
Aug 18 '14 at 15:49
source share

Oddly enough, you get an interactive console with Jython ! You are no longer like Python.

+10
Apr 24 '09 at 20:04
source share

Try Dr Java Interaction Panel.

+9
Nov 20
source share

You can also run the interactive Scala interpreter.

+4
Apr 24 '09 at 20:13
source share

The approach that I used for some degree of success is debugging in Eclipse and using display. What you see on the screen is the ability to control the code currently executing in the JVM by executing Java instructions. Any object that is accessible at a particular breakpoint that you stopped at is in scope. Although this is not exactly what you are looking for, it provides some of the features that REPL provides for other programming environments. See Debugging with the Eclipse Platform for more information.

+3
Apr 24 '09 at 20:01
source share

You may be interested in Groovy .

+2
Apr 24 '09 at 19:55
source share

The Jgrasp IDE has an interactive console where you can test, I use it a lot, and there is alos debug view showing variabel, etc. after you announce them.

It opens and you can get a copy of http://www.jgrasp.org/

// Anders

+1
Nov 23 '09 at 10:08
source share

You can use BeanShell to run arbitrary Java code. If you want to integrate Eclipse, EclipseShell supports BeanShell.

+1
Nov 02 2018-10-11T00:
source share

I sometimes run into the same problem and have a partial solution. I keep around the file (as Charlie Martin said, Java needs class contexts), which is a bit more than a test program. In the second window - the console - I have a script that I run that checks the modification time of the source file every second or two. When he sees a source change, he recompiles it (I usually play in C, but I did it with Java too) and performs the result.

This is not a great solution, but its quick one-time, and I found it very useful.

0
April 24. '09 at 19:59
source share



All Articles