Does scala have something similar to jython standalone jar?

Using jython standalone jar you can:

java -jar jython-standalone-2.5.3.jar 

And the replica begins.

I would like to do this with scala:

 java -jar scala-standalone.jar 

This will replace me with scala.

Let me ask about it differently. How do you call scala repl using Java.

 java -cp <jars> <class-with-main-method> 

In paticular, I don't want to use scala cli or even install it.

+4
source share
3 answers

You can definitely do this via java -jar , but I think it will not be as simple as jython. For example, if you look at scala.bat (on windows) in a standard scala installation, you will see that it uses some variant of the following command:

 "java" -Xmx256M -Xms32M -Dscala.home="C:\PROGRA~2\scala\bin\.." -Denv.emacs="" -Dscala.usejavacp=true -cp "C:\PROGRA~2\scala\bin\..\lib\jline.jar; C:\PROGRA~2\scala\bin\..\lib\scala-actors.jar; C:\PROGRA~2\scala\bin\..\lib\scala-compiler.jar; C:\PROGRA~2\scala\bin\..\lib\scala-library.jar; C:\PROGRA~2\scala\bin\..\lib\scala-partest.jar; C:\PROGRA~2\scala\bin\..\lib\scala-reflect.jar; C:\PROGRA~2\scala\bin\..\lib\scala-swing.jar; C:\PROGRA~2\scala\bin\..\lib\scalacheck.jar; C:\PROGRA~2\scala\bin\..\lib\scalap.jar" scala.tools.nsc.MainGenericRunner 

All on one line, of course. I made cd in the scala installation directory and then in the bin folder and executed this command directly. This gave me scala repl.

I assume that you can probably skip some of the jars (swings, actors, etc.), combine the others into one jar and get rid of some command line options, and then discard it using java -jar myscala.jar

PS: If you are trying to do something with Android, beware that this will not work. Because I tried this before: Scala REPL in Android app

: D

+1
source

You can build it yourself if necessary. There is a recent blog post that shows how to create a REPL. If you create this code using sbt and run the sbt-assembly plugin, you should get a standalone REPL via sbt assembly .

+2
source
0
source

All Articles