3

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)
2
  • 1
    I'll try it now @GhostCat sorry I didn't check it later in the day Commented Dec 8, 2017 at 8:16
  • @GhostCat sorry for the delay. Commented Dec 8, 2017 at 14:32

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Welcome to Scala version 2.11.6 (OpenJDK 64-Bit Server VM, Java 1.8.0_151). Type in expressions to have them evaluated. Type :help for more information. scala>

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.