1

When scala REPL starts some default packages like scala.lang._ , scala.Predef are automatically available.Suppose I have my own package like com.raghhuraamm.rUtils._

How to import this package automatically when REPL starts? Is there a way or I just have to type "import com.raghhuraamm.rUtils._ " every time I start scala REPL?

RAGHHURAAMM
  • 1,101
  • 5
  • 14

2 Answers2

1

If you could use sbt console to launch the REPL, you can create a build.sbt containing this line:

initialCommands in Compile in console += "import com.raghhuraamm.rUtils._"

Source: https://www.scala-sbt.org/1.x/docs/Inspecting-Settings.html

László van den Hoek
  • 3,745
  • 1
  • 23
  • 28
0

Create a script (myPreload.scala, say) that contains all the imports that you want:

// in myPreload.scala
import com.raghhuraamm.rUtils._

Assuming that the classes are packaged in my.jar, start the scala repl as follows:

scala -cp path/to/my.jar -i some/other/path/to/myPreload.scala
Andrey Tyukin
  • 41,173
  • 4
  • 44
  • 82