问题
I'm trying to run Scala in my command line.
I checked my java, went to the Scala website, downloaded and installed it, updated my environment variables.
So far the only thing different from guides online is that the folder where sbt
is installed does not include a "lib" folder.
I then run sbt
command in my prompt, and I get this message:
It looks like I'm missing a file called build.sbt
, what is this? and do i need it?
Edit:
If I press 'continue' on the picture above, I get
sbt:scalaproj>
Which looks fine, but if i type some code, like this:
sbt:scalaproj> var a : Int = 12;
Then it returns errors:
[error] Expected ';'
[error] var a : Int = 12
What in the world is going wrong? can someone point me to a guide for writing Scala in the prompt that is not too old to work?
回答1:
Let's first understand the terminology. Scala is the language you are writing. SBT is an acronym for Scala Build Tool. Both of them have REPL.
When you call sbt
in the command line, you initiate the REPL of sbt
. The commands you can run there, are all commands sbt
supports. You can find here the common commands. For example, if you run compile, it will compile the build.sbt
located at the directory where you called the sbt
command. Anyway, Scala commands WILL NOT work here. Scala commands are not sbt
commands.
In order to run Scala REPL, you need to type console
in the sbt
REPL. You can find here the Scala REPL documentation. Within the Scala REPL you can run Scala commands.
P.S. You can find the Scala download page here.
来源:https://stackoverflow.com/questions/63119194/running-scala-in-cmd-makes-i-look-like-i-am-missing-build-sbt