Java 在 Dos 命令提示符中检查 Scala 的当前版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25858299/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 01:19:49  来源:igfitidea点击:

Check Curent Version of Scala inside Dos Command Prompt

javascala

提问by Kick Buttowski

Is there any way to find current version of Scalathat I installed from command prompt?

有什么方法可以找到Scala我从命令提示符安装的当前版本吗?

As you know in command prompt Java -versiongives us current version of Javain the system, and I am wondering if there is any command for Scalathat gives me its current version.

正如您在命令提示符中所知道的那样Java -version,我们提供Java了系统中的当前版本,我想知道是否有任何命令Scala可以为我提供当前版本。

I follow this instruction to set up Scalain Windows

我按照此说明ScalaWindows 中进行设置

  1. Download the sbt installer from here: http://scalasbt.artifactoryonline.com/scalasbt/sbt-native-packages/org/scala-sbt/sbt/0.12.4/sbt.msi
  2. Run the installer
  1. 从这里下载 sbt 安装程序:http://scalasbt.artifactoryonline.com/scalasbt/sbt-native-packages/org/scala-sbt/sbt/0.12.4/sbt.msi
  2. 运行安装程序

Verify that sbt is installed correctly: open the Command Prompt and type sbt sbt-version, you should see the version number of sbt (the first time you run it, sbt will download libraries from the internet). If you have problems installing sbt, ask for help on the forums.

验证 sbt 是否安装正确:打开命令提示符并键入sbt sbt-version,您应该会看到 sbt 的版本号(第一次运行它时,sbt 会从互联网上下载库)。如果您在安装 sbt 时遇到问题,请在论坛上寻求帮助。

And the tutorial says, it download dependencies when sbt sbt-versiois ran or may be I got that wrong?

教程说,它在sbt sbt-versio运行时下载依赖项,还是我弄错了?

采纳答案by marekinfo

Looks like you just need to go to the Windows shell, start SBT and check the Scala version there, e.g.

看起来您只需要转到 Windows shell,启动 SBT 并检查那里的 Scala 版本,例如

C:\> sbt

> scala-version

2.9.2 (or whatever)

Now, you have the SBT prompt and can type "console" to open the Scala REPL:

现在,您有了 SBT 提示符,可以输入“console”来打开 Scala REPL:

> console

scala> println("Hello")

Hello

You can quit the repl with :q and go back to the SBT prompt

您可以使用 :q 退出 repl 并返回到 SBT 提示符

scala> :q

>

Now you can quit SBT using Ctrl+C to go back to the Windows prompt:

现在您可以使用 Ctrl+C 退出 SBT 以返回到 Windows 提示符:

C:\>

回答by marekinfo

You are likely using Scala from within SBT, but you don't have it installed in "stand-alone" mode - or, you simply don't have Scala on your shell path. See if you have SBT on your path (on a Unix-like OS like OS X, Linux, etc.):

您可能在 SBT 中使用 Scala,但您没有在“独立”模式下安装它 - 或者,您的 shell 路径中根本没有 Scala。查看您的路径上是否有 SBT(在类 Unix 的操作系统上,如 OS X、Linux 等):

which sbt

If you have SBT on your path, try

如果您的路径上有 SBT,请尝试

sbt scala-version

Note however that SBT can provide different versions of Scala (the library, compiler, etc.) depending on how your SBT project was set up. This is not a globally applicable version.

但是请注意,根据 SBT 项目的设置方式,SBT 可以提供不同版本的 Scala(库、编译器等)。这不是全球适用的版本。

If you're on a Unix-like OS (OS X, Linux, etc.) and you suspect you have Scala already installed, you can try searching for where Scala is installed if it's not already on your path

如果您使用的是类 Unix 操作系统(OS X、Linux 等)并且您怀疑自己已经安装了 Scala,那么您可以尝试搜索 Scala 的安装位置(如果它不在您的路径上)

sudo find / -name *scala* 2> /dev/null

回答by V. Kovpak

This one works for me:

这个对我有用:

sbt scalaVersion

回答by Marouane GhouLami

You can just run from any command line :

您可以从任何命令行运行:

C:\>scala

C:\>scala