When i use cmd enter scala there have a java.lang.NullPointerException

#1

the error is :

java.lang.NullPointerException
at java.util.Arrays.sort(Arrays.java:1438)
at scala.tools.nsc.classpath.JFileDirectoryLookup.listChildren(DirectoryClassPath.scala:125)
at scala.tools.nsc.classpath.JFileDirectoryLookup.listChildren$(DirectoryClassPath.scala:109)
at scala.tools.nsc.classpath.DirectoryClassPath.listChildren(DirectoryClassPath.scala:292)
at scala.tools.nsc.classpath.DirectoryClassPath.listChildren(DirectoryClassPath.scala:292)
at scala.tools.nsc.classpath.DirectoryLookup.list(DirectoryClassPath.scala:85)
at scala.tools.nsc.classpath.DirectoryLookup.list$(DirectoryClassPath.scala:81)
at scala.tools.nsc.classpath.DirectoryClassPath.list(DirectoryClassPath.scala:292)
at scala.tools.nsc.classpath.AggregateClassPath.$anonfun$list$1(AggregateClassPath.scala:85)
at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:237)
at scala.collection.Iterator.foreach(Iterator.scala:941)
at scala.collection.Iterator.foreach$(Iterator.scala:941)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1429)
at scala.collection.IterableLike.foreach(IterableLike.scala:74)
at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
at scala.collection.TraversableLike.map(TraversableLike.scala:237)
at scala.collection.TraversableLike.map$(TraversableLike.scala:230)
at scala.collection.AbstractTraversable.map(Traversable.scala:108)
at scala.tools.nsc.classpath.AggregateClassPath.list(AggregateClassPath.scala:83)
at scala.tools.nsc.symtab.SymbolLoaders$PackageLoader.doComplete(SymbolLoaders.scala:285)
at scala.tools.nsc.symtab.SymbolLoaders$SymbolLoader.complete(SymbolLoaders.scala:231)
at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1542)
at scala.reflect.internal.Mirrors$RootsBase.init(Mirrors.scala:232)
at scala.tools.nsc.Global.rootMirror$lzycompute(Global.scala:73)
at scala.tools.nsc.Global.rootMirror(Global.scala:71)
at scala.tools.nsc.Global.rootMirror(Global.scala:44)
at scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass$lzycompute(Definitions.scala:294)
at scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass(Definitions.scala:294)
at scala.reflect.internal.Definitions$DefinitionsClass.init(Definitions.scala:1463)
at scala.tools.nsc.Global$Run.(Global.scala:1194)
at scala.tools.nsc.interpreter.IMain._initialize(IMain.scala:132)
at scala.tools.nsc.interpreter.IMain.initializeSynchronous(IMain.scala:154)
at scala.tools.nsc.interpreter.ILoop.$anonfun$process$11(ILoop.scala:1055)
at scala.tools.nsc.interpreter.ILoop.startup$1(ILoop.scala:1036)
at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:1074)
at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:89)
at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:92)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:103)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:108)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)

computer path is right and use “scala -version” in cmd is successful.


i just can’t use “scala” in cmd enter scala shell

#2

My guess is your Scala installation has somehow become corrupted. Can you uninstall and reinstall?

#3

yes,I uninstall and reinstall,but there are still have errors:(

#4

perhaps your Scala is fine but the JVM you’re using is messed up. what JVM is it?

1 Like
#5

Hi @SethTisue,
I am also facing the same issue. And iam using the follow Scala code runner version 2.12.8 – Copyright 2002-2018, LAMP/EPFL and Lightbend, Inc.

Below is stack trace.

scala libs* build/libs/ness-poc-1.0.jar com.scala.Main
java.lang.NullPointerException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at scala.reflect.internal.util.ScalaClassLoader.$anonfun$tryClass$1(ScalaClassLoader.scala:52)
at scala.util.control.Exception$Catch.$anonfun$opt$1(Exception.scala:246)
at scala.util.control.Exception$Catch.apply(Exception.scala:228)
at scala.util.control.Exception$Catch.opt(Exception.scala:246)
at scala.reflect.internal.util.ScalaClassLoader.tryClass(ScalaClassLoader.scala:52)
at scala.reflect.internal.util.ScalaClassLoader.tryToInitializeClass(ScalaClassLoader.scala:48)
at scala.reflect.internal.util.ScalaClassLoader.tryToInitializeClass$(ScalaClassLoader.scala:48)
at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.tryToInitializeClass(ScalaClassLoader.scala:132)
at scala.reflect.internal.util.ScalaClassLoader.run(ScalaClassLoader.scala:99)
at scala.reflect.internal.util.ScalaClassLoader.run$(ScalaClassLoader.scala:98)
at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:132)
at scala.tools.nsc.CommonRunner.run(ObjectRunner.scala:28)
at scala.tools.nsc.CommonRunner.run$(ObjectRunner.scala:27)
at scala.tools.nsc.JarRunner$.run(MainGenericRunner.scala:21)
at scala.tools.nsc.CommonRunner.runAndCatch(ObjectRunner.scala:35)
at scala.tools.nsc.CommonRunner.runAndCatch$(ObjectRunner.scala:34)
at scala.tools.nsc.JarRunner$.runAndCatch(MainGenericRunner.scala:21)
at scala.tools.nsc.JarRunner$.runJar(MainGenericRunner.scala:33)
at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:79)
at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:92)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:103)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:108)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)

#6

Below is the jvm details.
java version “1.8.0_201”
Java™ SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot™ 64-Bit Server VM (build 25.201-b09, mixed mode)

#7

Does it also fail even on a simple hello-world program with nothing extra on the classpath?

#8

I haven’t tried for hello-world program