As a JVM language, Scala requires the use of a Java runtime. Scala 2.11, the version you’ll be using, needs at least Java 6.
However, I recommend installing the Java 8 JDK (aka Java SE for Standard Environment) instead for optimal performance. You can download the Java 8 JDK (or a later version, if available) for most platforms directly from Oracle’s website. Installers are available, so you shouldn’t need to manually configure your PATH variable to get the applications installed.
When finished, verify your Java version by running java -version from the command line. Here is an example of running this command for Java 8:
$ java -version
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
When finished, verify your Java version by running java -version from the command line. Here is an example of running this command for Java 8:
$ java -version
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
Now that Java is installed, it’s time to install Scala. There are two ways to install Scala (or any other fine programming tool): the manual approach, suitable for command line heroes who like to modify their system’s environment variables, and the automatic approach, for the rest of us.
To install Scala manually, download the Scala 2.11 distribution from http://www.scala-lang.org and add its “bin” directory to your path. The distribution includes the Scala run times, tools, compiled libraries, and source, but the most important item we’ll need is the scala command.
To install Scala manually, download the Scala 2.11 distribution from http://www.scala-lang.org and add its “bin” directory to your path. The distribution includes the Scala run times, tools, compiled libraries, and source, but the most important item we’ll need is the scala command.
This command provides (among other features) the REPL (Read-Eval-Print-Loop) shell we will use to learn and experiment with the Scala language.
To install Scala automatically, use a package manager such as Homebrew for OS X, Chocolatey for Windows, or apt-get/Yum for Linux systems. These are freely available and will handle finding the package, downloading and extracting it, and installing it so you can access it from the command line.
The scala package is available in all of these package managers as “scala,” so you can install it with (brew/choco/apt-get-yum) install scala .
When installed, execute the scala command from the command line. You should see a welcome message like the following (although your Scala and Java version messages may be different):
$ scala
Welcome to Scala version 2.11.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_05).
Type in expressions to have them evaluated.
Type :help for more information.
scala>
When you see the Welcome to Scala message and the scala> prompt you are now in the Scala REPL and are ready to start coding.
If the command is found but there are problems launching it, make sure your Java command is installed correctly and that your system path points to the correct Java version.
$ scala
Welcome to Scala version 2.11.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_05).
Type in expressions to have them evaluated.
Type :help for more information.
scala>
When you see the Welcome to Scala message and the scala> prompt you are now in the Scala REPL and are ready to start coding.
If the command is found but there are problems launching it, make sure your Java command is installed correctly and that your system path points to the correct Java version.
Introduction to SCALA : Why Scala ? Day 1 Learnings
http://kalyanbigdatatraining.blogspot.in/2016/10/introduction-to-scala-why-scala-day-1.html
Share this article with your friends.
No comments :
Post a Comment