I would like to launch a Scala Swing application from the command line, then after the application is started, drop into the Scala REPL to use as a control interface.
Ideally I would also like to pre-bind some variable names. Even better would be using a Java2D terminal emulator for the REPL, but I couldn't find anything appropriate.
Does the Scala REPL have a public API?
We can start Scala REPL by typing scala command in console/terminal.
The Scala REPL is a tool (scala) for evaluating expressions in Scala. The scala command will execute a source script by wrapping it in a template and then compiling and executing the resulting program.
The Scala REPL (Read-Eval-Print-Loop) is a development tool to interpret fragments of Scala code. It doesn't require too much setup or infrastructure and it is going to be essential during your learning journey. Using the REPL, you'll be able to play and experiment with the language by typing and evaluating code.
To run Scala from the command-line, download the binaries and unpack the archive. Start the Scala interpreter (aka the “REPL”) by launching scala from where it was unarchived. Start the Scala compiler by launching scalac from where it was unarchived.
You are may be asking about the same thing, as this question, are you? There is other stuff you can do. There's a way to just call REPL with a code, and get an answer back, which, depending on what you want, may be more appropriate. If that's what you want, just clarify it and I'll research into it.
As for Java2D terminal, I think it is enough to use Console
's setIn
, setOut
and setErr
, but I might be mistaken. You might want to take a look at how some other efforts which embed REPL in the environment do. I think there are at least three of them, but a quick search only Kojo, which is based on Netbeans.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With