Hani Gotc
Hani Gotc

Reputation: 890

Scala throws an exception when I try to launch it on ubuntu

I am trying to launch scala on Ubuntu 16.04.3. I installed java and scala but when I type scala in the terminal, all of a sudden it throws an exception.


Step 1: Installating Java and Scala

First, I Installed Java by following these steps described in How to install java:

 - $sudo apt-get update
 - $sudo apt-get install default-jre
 - $sudo apt-get install default-jdk
 - $sudo add-apt-repository ppa:webupd8team/java
 - $sudo apt-get update
 - $sudo apt-get install oracle-java9-installer

When I type $java -version I get:

java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

Second, I installed scala by using the following command $sudo apt-get install scala


Step 2: Running scala

From the console when I type $scala I get the following exception:

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)

Upvotes: 3

Views: 3633

Answers (1)

GhostCat
GhostCat

Reputation: 140417

It seems that there are various issues with Scala in combination with Java9 ( see here for example ).

The upcoming release Scala 2.12.4 is supposed to fix some of these.

At this point in time, the "best" option is probably to not install Java9, but to go with Java8. See here for guidance how to do that.

Upvotes: 3

Related Questions