Running scala in cmd makes i look like I am missing 'build.sbt'

我与影子孤独终老i 提交于 2021-02-11 12:53:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!