2

If we have a new computer - can we install only Scala (and no Java) and run Scala code?

If no - why not? What exactly Scala uses from Java? Is it only JRE or JDK is also needed?

Also what difference makes when installing e.g. Java 8 or 9 or 10 before running Scala? (performance difference or some other for scala for any of these?)

Maroun
  • 94,125
  • 30
  • 188
  • 241
cikavladimir
  • 443
  • 2
  • 5
  • 11
  • Possible duplicate of [Can I run my scala program without JVM using scala-native?](https://stackoverflow.com/questions/37445475/can-i-run-my-scala-program-without-jvm-using-scala-native) – jhamon Mar 26 '18 at 14:40
  • @jhamon - Not a dup of that Q. As of now, it looks like scala-native is incomplete. – Stephen C Mar 26 '18 at 15:42

2 Answers2

2

The Scala compiler (scalac) produces JVM bytecode (.class files), as much as the Java compiler (javac).

To execute these files you need a JVM. So, technically, a JRE is enough.

Moreover, Scala depends on Java types provided by the JRE (e.g. String, Integer, etc), so you definitely cannot run any Scala program without those.

As per the version of Java support, Scala 2.12 requires Java 8, and it technically works with Java 9 and 10 too, but there are still compatibility issues. See https://github.com/scala/scala-dev/issues/139

Gabriele Petronella
  • 106,943
  • 21
  • 217
  • 235
1

You will need Java to run Scala code. If you only want to run but not compile Scala code, JRE should be enough.

JRE provides the JVM and Java libraries that Scala wraps over.

Current version of Scala seems to require Java 8 or above. The different in using 8, 9 and 10 should be in terms of JVM performance and bugs.

NOLFXceptMe
  • 232
  • 1
  • 10