如何获得 Java 的交互式 shell(如 Ruby 的 irb)?
去年我从事 Ruby 开发,在那段时间我发现了 irb,它使得运行小型“代码实验”变得简单而有趣。我最近换了团队,现在正在做Java开发,我发现我真的很怀念我的irb窗口。我想对 Java 做同样的事情,但我不知道如何做。
我正在使用 Eclipse(呻吟),但 Eclipse 的花哨功能并不是一回事。
I spent the last year doing Ruby development, and during that time I discovered irb, which makes running little "code experiments" easy and fun. I've recently switched teams and am now doing Java development, and I've found that I really miss my irb window. I would like to do the same thing for Java, but I don't know how.
I'm using Eclipse (groan), but Eclipse's bells and whistles are not the same thing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
BeanShell 可能就是您正在寻找的。
https://github.com/beanshell/beanshell
BeanShell is probably what you're looking for.
https://github.com/beanshell/beanshell
有几个选择: BeanShell 已经存在很长时间了,并且是一个很棒的 Java REPL。
另一种选择是 groovy 的 groovysh 或 groovyConsole。虽然 groovy 不是严格意义上的 Java,但它非常适合以交互方式使用 Java 类。
There are a few choices: BeanShell has been around for a long time, and is a great Java REPL.
Another alternative is groovy's groovysh or groovyConsole. While groovy isn't Java in the strict sense, it's great for interactively playing around with Java classes.
老问题,我知道,但是jshell:Java Shell(读取-评估-打印循环), Java 9 即将推出(希望是 2017 年夏季)。
Old question, I know, but jshell: The Java Shell (Read-Eval-Print Loop), is coming in Java 9 (Summer 2017, hopefully).
“使用 Eclipse Java 剪贴簿页面”会更好吗;-)
我实际上没有使用过 irb,但如果您只想在 eclipse 内运行代码片段,那么这是一种简单的方法。
Would "Use an Eclipse Java Scrapbook page" be better ;-)
I haven't actually used irb, but if you just want to run code snippets inside of eclipse, then this is a simple way of doing it.
尝试过 JShell 和 beanshell。
建议使用 JShell 而不是 beanshell。向上键将回滚到历史行。显示非常用户友好。
谢谢@Anders Sandvig,
它可以在jdk中找到,因为java 9。
Tried JShell and beanshell.
Do suggest JShell over beanshell. Up key will roll back to history lines. Display much user friendly.
Thank you @Anders Sandvig
It can be found in jdk since java 9.