Latest web development tutorials

Scala installation and configuration environment

Scala language can run on Window, Linux, Unix, Mac OS X systems.

Scala is based on java, you must install the Java (> 1.5 versions) Before using the java libraries and a large number of variables, you must use Scala.


Scala installation on Mac OS X and Linux

The first step: Java settings

Make sure you install a local and JDK 1.5 or later, and set up JAVA_HOME environment variables and the JDK bin directory.

We can use the following command to check whether the installed Java:

$ java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
$

Then we can see if the installed Java compiler. Enter the following command:

$ javac -version
javac 1.8.0_31
$

If it is installed, you can refer to our Java Development environment configuration .

Next, we can from Scala official website address http://www.scala-lang.org/downloads Download Scala binary package for this tutorial we will download the2.11.7version, as shown below:

Unzip the file package, which can be moved to under / usr / local / share:

mv scala-2.11.7 scala                   # 重命名 Scala 目录
mv /download/scalapath /usr/local/share # 下载目录需要按你实际的下载路径

Modify environment variables, if not into the administrators can use sudo administrator privileges, modify the configuration file profile:

vim /etc/profile

或

sudo vim /etc/profile

At the end of the file is added:

export PATH="$PATH:/usr/local/share/scala/bin"

:! Wq save and exit and restart the terminal, execute the scala command, the following output information indicates that the installation was successful:

$ scala
Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_31).
Type in expressions to have them evaluated.
Type :help for more information.

Note: at compile time, if Chinese will be garbled phenomenon, Solution View: Scala solve the Chinese garbled


Install Scala on window

The first step: Java settings

Qian Wenyi detection method described here will not be described.

If it is installed, you can refer to our Java development environment configuration .

Next, we can from Scala official website address http://www.scala-lang.org/downloads Download Scala binary package for this tutorial we will download the2.11.7version, as shown below:

After downloading, double-click the msi file, can be a step by step installation, the installation process you can use the default installation directory.

After installing the scala, the system will automatically prompt, click finish, to complete the installation.

Right-click My Computer, click "Properties" to enter the page shown in Figure. Let's start to configure the environment variables, right-click My Computer] - [Properties] - [Advanced System Settings] - [Environment variables], as shown:

Setting SCALA_HOME variable: Click New, enter the variable name column:SCALA_HOME: Variable Value column, enter:D: \ Program Files \ scala scala is the installation directory, vary according to individual circumstances, if installed in C drive, will "D" changed to "C" can be.

Setting Path variable: find the "Path" variable under the system as shown, you click Edit. In the "Variable Value" column top add the following path:% SCALA_HOME% \ bin;% SCALA_HOME% \ jre \ bin;

Note: the semicolon;do not miss.

Setting Classpath variables: the system variables found under the "Classpath" figure, click Edit, and if not, then click the "New":

  • "Variable name": ClassPath
  • "Variable value":;.% SCALA_HOME% \ bin;% SCALA_HOME% \ lib \ dt.jar;% SCALA_HOME% \ lib \ tools.jar .;

Note: The "variable value" front; do not miss.Finally, click OK.

Check the environment variable is set up: tune out "cmd" checked. Click [Start], type in the input box cmd, then "Enter", enter scala, and then return, such as the environment variable settings ok, you should be able to see this information.

The following lists the different systems can be placed in the directory (as a reference):

System Environment variable Value (for example)
Unix $SCALA_HOME /usr/local/share/scala
$PATH $PATH:$SCALA_HOME/bin
Windows %SCALA_HOME% c:\Progra~1\Scala
%PATH% %PATH%;%SCALA_HOME%\bin