Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
223 views
in Technique[技术] by (71.8m points)

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

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:

enter image description here

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...