16

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?

oluies
  • 17,694
  • 14
  • 74
  • 117
sanity
  • 35,347
  • 40
  • 135
  • 226
  • 2
    Are you looking to break into the REPL mid-execution (based on some condition), run the REPL in parallel on a separate thread, connect to a remote VM, or just pull your project into scope on the REPL classpath? – Kevin Wright Oct 11 '10 at 12:36
  • Like http://stackoverflow.com/questions/2160355/drop-into-interpreter-during-arbitrary-scala-code-location? – Daniel C. Sobral Oct 11 '10 at 20:10

2 Answers2

4

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

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.

I wanted to run Scala code as part of testing, so I've implemented CompilerMatcher following his article.

Eugene Yokota
  • 94,654
  • 45
  • 215
  • 319
  • 4
    Unfortunately as of now, that link requires signing up to blogger and getting an invitation to the blog. – mseddon Mar 26 '14 at 00:21
2

Here's an example of providing an embedded scala 2.9.1 over ssh: scala-ssh-shell

srparish
  • 1,708
  • 1
  • 16
  • 22