scala SBT 使用哪个版本的 Java?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20371144/
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
Which version of Java does SBT use?
提问by Seth Tisue
How to find out, which version of JDK SBT uses?
如何找出使用哪个版本的 JDK SBT?
My laptop has both JDK 1.6 and JDK 1.7 installed, so I was just wondering.
我的笔记本电脑同时安装了 JDK 1.6 和 JDK 1.7,所以我只是想知道。
采纳答案by Jonny Coombes
Just run sbt console and you'll get something like this:
只需运行 sbt 控制台,你就会得到这样的信息:
Welcome to Scala version 2.10.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_45). Type in expressions to have them evaluated. Type :help for more information.
欢迎使用 Scala 版本 2.10.2(Java HotSpot(TM) 64 位服务器 VM,Java 1.6.0_45)。输入表达式以对它们进行评估。输入 :help 以获取更多信息。
Which shows you the version of Java being used.
它显示了正在使用的 Java 版本。
Cheers
干杯
JC
JC
回答by Seth Tisue
You can use evalat the sbt prompt with the appropriate system properties:
您可以eval在 sbt 提示符下使用适当的系统属性:
> eval System.getProperty("java.version")
[info] ans: String = 1.7.0_45
> eval System.getProperty("java.home")
[info] ans: String = /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre
(The other answers are fine too, this is just another method.)
(其他答案也很好,这只是另一种方法。)
回答by Jonny Coombes
It's actually easy.
其实很简单。
Find the command line of SBT (cat `which sbt`) and see which Java it is.
找到SBT( cat `which sbt`)的命令行,看看是哪个Java。
For example, my SBT command line begins with:
例如,我的 SBT 命令行以:
/usr/bin/java -Xmx512M
And /usr/bin/java -versiontells the Java version, in my case it is 1.7.
并/usr/bin/java -version告诉 Java 版本,在我的情况下它是 1.7。
回答by qu1j0t3
sbt -vis another way:
sbt -v是另一种方式:
# sbt -v
[process_args] java_version = '1.7.0_121'
# Executing command line:
java
-Xms1024m
-Xmx1024m
-XX:ReservedCodeCacheSize=128m
-XX:MaxPermSize=256m
-jar
/usr/share/sbt-launcher-packaging/bin/sbt-launch.jar
[info] Loading project definition from /root/.sbt/0.13/staging/a6d8e5030b69785a9763/build/project
[info] Set current project to xx (in build file:/build/)
>
回答by ManoDestra
Here's a batch file method I created to get that info immediately from the command line (Windows only, but you can do something similar in a shell script):
这是我创建的一个批处理文件方法,用于立即从命令行获取该信息(仅限 Windows,但您可以在 shell 脚本中执行类似操作):
@echo off
setlocal
sbt "eval System.getProperty(\"java.version\")" "eval System.getProperty(\"java.home\")"
@echo on

