在 cmd 中运行 scala 让我看起来好像缺少“build.sbt" [英] Running scala in cmd makes i look like I am missing 'build.sbt'

查看:34
本文介绍了在 cmd 中运行 scala 让我看起来好像缺少“build.sbt"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在命令行中运行 Scala.

I'm trying to run Scala in my command line.

我检查了我的 java,去了 Scala 网站,下载并安装了它,更新了我的环境变量.

I checked my java, went to the Scala website, downloaded and installed it, updated my environment variables.

到目前为止,与在线指南唯一不同的是安装 sbt 的文件夹不包含lib".文件夹.

So far the only thing different from guides online is that the folder where sbt is installed does not include a "lib" folder.

然后我在我的提示中运行 sbt 命令,然后我收到这条消息:

I then run sbt command in my prompt, and I get this message:

我好像缺少一个名为 build.sbt 的文件,这是什么?我需要吗?

It looks like I'm missing a file called build.sbt, what is this? and do i need it?

如果我在上面的图片上按继续",我会得到

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;

然后它返回错误:

[error] Expected ';'
[error] var a : Int = 12

这到底是怎么回事?有人可以指点我在提示中编写 Scala 的指南,该指南不会太旧而无法工作吗?

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?

推荐答案

我们先来了解一下术语.Scala 是您正在编写的语言.SBT 是 Scala 构建工具的首字母缩写词.他们都有 REPL.

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.

当您在命令行中调用 sbt 时,您启动了 sbt 的 REPL.你可以在那里运行的命令,都是 sbt 支持的命令.您可以在此处找到常用命令.例如,如果您运行 compile,它将编译位于您调用 sbt 命令的目录中的 build.sbt.无论如何,Scala 命令在这里不起作用.Scala 命令不是 sbt 命令.

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.

为了运行 Scala REPL,您需要在 sbt REPL 中键入 console.您可以在此处找到 Scala REPL 文档.在 Scala REPL 中,您可以运行 Scala 命令.

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.

附言您可以在此处找到 Scala 下载页面.

P.S. You can find the Scala download page here.

这篇关于在 cmd 中运行 scala 让我看起来好像缺少“build.sbt"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆