How do I compile Java 8 sources with SBT

泄露秘密 提交于 2019-12-24 14:27:55

问题


I am trying to compile a project containing some Java 8 source files using lambdas using SBT 0.13.7. Now, I set

-java-home /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Home

in

/usr/local/etc/sbtopts

And apparently SBT does take this into consideration, because if I supply the wrong path it complains about no java being present.

However, when I try compiling, I get the following

[error] /Users/edafinov/GitRepos/Java8SBTTest/src/main/java/Main.java:10: error: illegal start of        expression
[error]     new ArrayList<Integer>().stream().filter(i -> i%2 ==0).count();
[error]                                                 ^
[error] 1 error
[error] (compile:compile) javac returned nonzero exit code
[error] Total time: 1 s, completed Dec 26, 2014 12:28:55 PM

This seems to indicate that SBT does not use javac 1.8, but rather the 1.7 one which is the default one for my system.

What am I doing wrong?

Thank you in advance


回答1:


Apparently if you have a JDK in the path, SBT would try to use that one, even when you have explicitly set the -java-home option. I solved my problem by removing the default JDK from $PATH



来源:https://stackoverflow.com/questions/27660083/how-do-i-compile-java-8-sources-with-sbt

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