如何在 Java 应用程序中嵌入 Scala 2.8 解释器? [英] How do I embed the Scala 2.8 interpreter in a Java application?
问题描述
为了调试目的,我希望能够在我的 Java 应用程序中以交互方式操作内存中的对象.我很想使用 Scala 的 2.8 解释器来做到这一点,利用其制表符完成等功能.我该怎么做?
I want to be be able to manipulate objects in memory in my Java app interactively for debugging purposes. I would quite like to do this using Scala's 2.8 interpreter, taking advantages of its features like tab-completion. How do I do this?
推荐答案
参见 Josh Suereth 的 嵌入 Scala 解释器.
See Josh Suereth's Embedding the Scala Interpreter.
您可以在下方看到自动完成建议.
You can see the auto-complete suggestions below.
josh@suereth-desktop:~/projects/blog/embed-the-interpreter$ java -jar target/embedded-interpreter-0.1-SNAPSHOT-jar-with-dependencies.jar
Welcome to Awesomeness!
This is my version of the Scala interpreter
TestInterpreter> j
java javax jline
我认为他还在 Eclipse 的 Scala IDE 中实现了该功能,因此您也可以查看一下.最新的是 在线提供.
I think he also implemented the feature into Scala IDE for Eclipse so you also take a look at that. The latest is available online.
我想运行 Scala 代码作为测试的一部分,所以我实现了 CompilerMatcher 关注他的文章.
I wanted to run Scala code as part of testing, so I've implemented CompilerMatcher following his article.
这篇关于如何在 Java 应用程序中嵌入 Scala 2.8 解释器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!