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.
我最近花了很多时间用Java编程,而我从脚本语言中遗漏的一件事就是能够在控制台中测试它们。
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.
要快速测试java程序,我必须编辑一个文件,然后将其转换为字节码并执行它。即使使用IDE,它在第372次之后也会失去乐趣。
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).
我想知道是否有一个产品具有任何像交互式控制台(我打赌你需要一个JIT编译器)和一些自动完成(具有反复性,我想它是可能的)。
Maybe that's something very common that I just don't know about or something completely impossible, but its worst asking :-)
也许这是我不知道的非常普遍或者完全不可能的事情,但最糟糕的是:-)
11 个解决方案
#1
36
Yes; jshell, and before that some close approximations are Groovy, Clojure, Scala, and the Bean Shell.
是; jshell,在此之前,一些近似的东西是Groovy,Clojure,Scala和Bean Shell。
#2
12
Funnily enough, you get an interactive console with Jython ! You don't get much more Python-like.
有趣的是,你可以通过Jython获得一个交互式控制台!你不会得到更像Python的东西。
#3
12
Java REPL http://www.javarepl.com/term.html
Java REPL http://www.javarepl.com/term.html
with an intellij plugin: http://plugins.jetbrains.com/plugin/7215?pr=
使用intellij插件:http://plugins.jetbrains.com/plugin/7215?pr =
#6
4
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 for more information.
我在某种程度上取得了成功的方法是在Eclipse中进行调试并使用显示视图。显示视图为您提供的是通过执行Java语句来操作当前在JVM中运行的代码的能力。在您停止的特定断点处可用的任何对象都在显示视图中的范围内。虽然这不是您正在寻找的,但它确实提供了REPL为其他编程环境提供的一些功能。有关更多信息,请参阅使用Eclipse Platform进行调试。
#7
4
You can execute Scala interactive interpreter too.
您也可以执行Scala交互式解释器。
#9
2
You can use BeanShell to run arbitrary Java code. If you want Eclipse integration, EclipseShell has BeanShell support.
您可以使用BeanShell运行任意Java代码。如果您想要Eclipse集成,EclipseShell可以支持BeanShell。
#10
1
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.
Jgrasp IDE有一个交互式控制台,您可以在其中进行测试,我经常使用它,并且还有一个调试视图显示变量等等,然后您将它们降级。
It is opensoruce and you can get a copy att http://www.jgrasp.org/
这是opensoruce,你可以获得一份副本http://www.jgrasp.org/
// Anders
//安德斯
#11
0
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.
我偶尔遇到同样的问题,并有一个部分解决方案。我保留了一个文件(正如Charlie Martin所说,Java需要它的类上下文),这只不过是一个测试程序。在第二个窗口 - 控制台 - 我运行的脚本只是每两秒或两次检查一次源文件的修改时间。当它看到源更改时,它重新编译它(我通常在C中摆弄,但我也用Java做过)并执行结果。
It's not a great solution, but its a fast one-off and I've found it to be very useful.
这不是一个很好的解决方案,但它是一个快速的一次性,我发现它非常有用。
#1
36
Yes; jshell, and before that some close approximations are Groovy, Clojure, Scala, and the Bean Shell.
是; jshell,在此之前,一些近似的东西是Groovy,Clojure,Scala和Bean Shell。
#2
12
Funnily enough, you get an interactive console with Jython ! You don't get much more Python-like.
有趣的是,你可以通过Jython获得一个交互式控制台!你不会得到更像Python的东西。
#3
12
Java REPL http://www.javarepl.com/term.html
Java REPL http://www.javarepl.com/term.html
with an intellij plugin: http://plugins.jetbrains.com/plugin/7215?pr=
使用intellij插件:http://plugins.jetbrains.com/plugin/7215?pr =
#4
#5
#6
4
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 for more information.
我在某种程度上取得了成功的方法是在Eclipse中进行调试并使用显示视图。显示视图为您提供的是通过执行Java语句来操作当前在JVM中运行的代码的能力。在您停止的特定断点处可用的任何对象都在显示视图中的范围内。虽然这不是您正在寻找的,但它确实提供了REPL为其他编程环境提供的一些功能。有关更多信息,请参阅使用Eclipse Platform进行调试。
#7
4
You can execute Scala interactive interpreter too.
您也可以执行Scala交互式解释器。
#8
#9
2
You can use BeanShell to run arbitrary Java code. If you want Eclipse integration, EclipseShell has BeanShell support.
您可以使用BeanShell运行任意Java代码。如果您想要Eclipse集成,EclipseShell可以支持BeanShell。
#10
1
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.
Jgrasp IDE有一个交互式控制台,您可以在其中进行测试,我经常使用它,并且还有一个调试视图显示变量等等,然后您将它们降级。
It is opensoruce and you can get a copy att http://www.jgrasp.org/
这是opensoruce,你可以获得一份副本http://www.jgrasp.org/
// Anders
//安德斯
#11
0
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.
我偶尔遇到同样的问题,并有一个部分解决方案。我保留了一个文件(正如Charlie Martin所说,Java需要它的类上下文),这只不过是一个测试程序。在第二个窗口 - 控制台 - 我运行的脚本只是每两秒或两次检查一次源文件的修改时间。当它看到源更改时,它重新编译它(我通常在C中摆弄,但我也用Java做过)并执行结果。
It's not a great solution, but its a fast one-off and I've found it to be very useful.
这不是一个很好的解决方案,但它是一个快速的一次性,我发现它非常有用。