How to specify which java version to use with sbt 0.12.4? I have java 7 and java 8 installed. Since sbt 0.12.4 does not support java 8 but tries to use it by default, I have to specify java version explicitly for sbt. I want to keep using java 8 as a default version of java for other things.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
One way that works well for me is, using the sbt script from sbt-extras and add to the root of the project a file called .sbtopts
with:
-java-home
/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home
using whatever version of Java 7 you want to use. Make sure that those are on separate.
回答2:
If you're not using the sbt script from sbt-extras you could use jEnv.
After configuring jEnv, from the root of the project run jenv local 1.7
, which will create a file called .java-version
with content "1.7".
Then every time you run java
(or javac
, etc) in that project (including from any directory in that project) it will run the 1.6 version, thanks to jEnv's shim mechanisms.