Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala project using sbt throws NullPointerException

Tags:

I cloned the project from here, and tried to load it in Terminal by opening the directory and using the command sbt. But this shows error like this:

java.lang.NullPointerException
    at java.base/java.util.regex.Matcher.getTextLength(Matcher.java:1769)
    at java.base/java.util.regex.Matcher.reset(Matcher.java:416)
    at java.base/java.util.regex.Matcher.<init>(Matcher.java:253)
    at java.base/java.util.regex.Pattern.matcher(Pattern.java:1130)
    at java.base/java.util.regex.Pattern.split(Pattern.java:1249)
    at java.base/java.util.regex.Pattern.split(Pattern.java:1322)
    at sbt.IO$.pathSplit(IO.scala:797)
    at sbt.IO$.parseClasspath(IO.scala:912)
    at sbt.compiler.CompilerArguments.extClasspath(CompilerArguments.scala:66)
    ...
    ...

I tried another project, pdffigures2. It shows similar error:

[info] Loading project definition from /path/to/project/pdffigures2/project
java.lang.NullPointerException
    at java.base/java.util.regex.Matcher.getTextLength(Matcher.java:1769)
    at java.base/java.util.regex.Matcher.reset(Matcher.java:416)
    at java.base/java.util.regex.Matcher.<init>(Matcher.java:253)
    at java.base/java.util.regex.Pattern.matcher(Pattern.java:1130)
    at java.base/java.util.regex.Pattern.split(Pattern.java:1249)
    at java.base/java.util.regex.Pattern.split(Pattern.java:1322)
    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)
    ...
    ...

and prompts me to retry, quit, last or ignore. I tried again, only to get the same result.

If it may help, I'm using Ubuntu 18.04.

like image 251
npk Avatar asked May 28 '18 05:05

npk


People also ask

How do I fix NullPointerException could be thrown?

NullPointerException is thrown when a reference variable is accessed (or de-referenced) and is not pointing to any object. This error can be resolved by using a try-catch block or an if-else condition to check if a reference variable is null before dereferencing it.

Is it good practice to throw NullPointerException?

If a caller passes null in some parameter for which null values are prohibited, convention dictates that NullPointerException be thrown rather than IllegalArgumentException .” So if you must allow NullPointerException in some places in your code then make sure you make them more informative than they usually are.

When should we throw a NullPointerException?

NullPointerException is thrown when an application attempts to use an object reference that has the null value. These include: Calling an instance method on the object referred by a null reference. Accessing or modifying an instance field of the object referred by a null reference.

Can you catch a NullPointerException?

Programmers typically catch NullPointerException under three circumstances: The program contains a null pointer dereference. Catching the resulting exception was easier than fixing the underlying problem. The program explicitly throws a NullPointerException to signal an error condition.


1 Answers

I had java version 10.x and javac version 1.8x. I downgraded java version to 8, and the problem seems to have fixed

like image 196
npk Avatar answered Sep 28 '22 17:09

npk