我是scala和sbt的新手,我想运行sbt命令,但我得到一些Nullpointer异常,不知道为什么。
我在系统中安装了scala:
scala -version Scala代码运行器版本2.11.8 - 版权所有2002-2016,LAMP / EPFL
此外,如果我尝试检查sbt版本工作正常:
sbt --version sbt launcher version 0.13.5
但是当我刚刚运行sbt时,我得到一个例外:
info] Loading project definition from /home/workspace/myproject
java.lang.NullPointerException
at java.util.regex.Matcher.getTextLength(java.base@9-internal/Matcher.java:1747)
at java.util.regex.Matcher.reset(java.base@9-internal/Matcher.java:402)
at java.util.regex.Matcher.<init>(java.base@9-internal/Matcher.java:244)
at java.util.regex.Pattern.matcher(java.base@9-internal/Pattern.java:1108)
at java.util.regex.Pattern.split(java.base@9-internal/Pattern.java:1221)
at java.util.regex.Pattern.split(java.base@9-internal/Pattern.java:1288)
at sbt.IO$.pathSplit(IO.scala:744)
at sbt.IO$.parseClasspath(IO.scala:859)
at sbt.compiler.CompilerArguments.extClasspath(CompilerArguments.scala:62)
at sbt.compiler.MixedAnalyzingCompiler$.withBootclasspath(MixedAnalyzingCompiler.scala:189)
at sbt.compiler.MixedAnalyzingCompiler$.searchClasspathAndLookup(MixedAnalyzingCompiler.scala:167)
at sbt.compiler.MixedAnalyzingCompiler$.apply(MixedAnalyzingCompiler.scala:177)
at sbt.compiler.IC$.incrementalCompile(IncrementalCompiler.scala:138)
at sbt.Compiler$.compile(Compiler.scala:128)
at sbt.Compiler$.compile(Compiler.scala:114)
at sbt.Defaults$.sbt$Defaults$$compileIncrementalTaskImpl(Defaults.scala:814)
at sbt.Defaults$$anonfun$compileIncrementalTask$1.apply(Defaults.scala:805)
at sbt.Defaults$$anonfun$compileIncrementalTask$1.apply(Defaults.scala:803)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon$4.work(System.scala:63)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.Execute.work(Execute.scala:235)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
at java.util.concurrent.FutureTask.run(java.base@9-internal/FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(java.base@9-internal/Executors.java:514)
at java.util.concurrent.FutureTask.run(java.base@9-internal/FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@9-internal/ThreadPoolExecutor.java:1158)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@9-internal/ThreadPoolExecutor.java:632)
at java.lang.Thread.run(java.base@9-internal/Thread.java:804)
[error] (compile:compileIncremental) java.lang.NullPointerException
知道如何解决这个问题吗?
答案 0 :(得分:0)
堆栈跟踪
Loading project definition from /home/workspace/myproject
java.lang.NullPointerException
at java.util.regex.Matcher.getTextLength(java.base@9-internal/Matcher.java:1747)
at java.util.regex.Matcher.reset(java.base@9-internal/Matcher.java:402)
at java.util.regex.Matcher.<init>(java.base@9-internal/Matcher.java:244)
at java.util.regex.Pattern.matcher(java.base@9-internal/Pattern.java:1108)
at java.util.regex.Pattern.split(java.base@9-internal/Pattern.java:1221)
at java.util.regex.Pattern.split(java.base@9-internal/Pattern.java:1288)
表示您尝试在JDK 9下运行sbt 0.13.5,当时不支持。正如thirstycrow在评论中所建议的那样,建议的做法是使用JDK 8。
如果您使用的是JDK 9或10,则使用最新的启动脚本可以更好地使用sbt 1.1.6或更高版本。