I just installed scala on Ubuntu
scala -version
Scala code runner version 2.11.6 -- Copyright 2002-2013, LAMP/EPFL
but when I try to run the scala command for an interactive shell session I have the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/script/Compilable
at scala.tools.nsc.interpreter.ILoop.createInterpreter(ILoop.scala:126)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:908)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:906)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:906)
at scala.reflect.internal.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:97)
at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:906)
at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:74)
at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:87)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:98)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:103)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
The version of Scala that you installed does not work with the version of Java that you installed.
Scala works well with Java 8. You probably have installed Java 9. The solution is to uninstall Java and install Java 8.
There are more issues with trying to use Java 9 or newer with Scala. Oracle has started changing the packaging and licensing for Java which means that some classes (imports) that Scala requires do not exist in Java SE 9+. Some have been moved to Java EE and some are deprecated. Stay with Java 8 with Scala.