How to specify which java version to use with sbt 0.12.4?

给你一囗甜甜゛ 提交于 2019-12-25 06:13:15

问题


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.



来源:https://stackoverflow.com/questions/30286058/how-to-specify-which-java-version-to-use-with-sbt-0-12-4

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!