Scala installation
Scala language can run on Window, Linux, Unix, Mac OS X and other systems.
Scala is based on java, using a lot of java class libraries and variables, using Scala
Java (> version 1.5) must be installed before.
Install Scala on Mac OS X and Linux
Step 1:Java setting
Make sure that you have installed JDK 1.5 or above locally and set the JAVA_HOME
environment variables and the bin directory of JDK.
We can use the following command to see if Java is installed:
$ 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)
$
Next, we can see if the Java compiler is installed. Enter the following command to view:
$ javac -version
javac 1.8.0_31
$
If it is not already installed, you can refer to our Java development environment configuration.
Next, we can download the Scala binary package from Scala’s official websitehttp://www.scala-lang.org/downloads. We will download version 2.11.7 of this tutorial, as shown in the following figure:
Extract the package and move it to /usr/local/share
:
mv scala-2.11.7 scala # Rename Scala directory
mv /download/scalapath /usr/local/share # The download directory needs to follow your actual download path
Modify the environment variable. If it is not an administrator, you can use sudo to enter the administrator privileges and modify the configuration profile
file :
vim /etc/profile
or
sudo vim /etc/profile
Add the following at the end of the file:
export PATH="$PATH:/usr/local/share/scala/bin"
:wq!
save exit, restart the terminal, execute scala
command to output the following information, indicating 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: if there is garbled code in Chinese during compilation, please see thesolution: Scala
Chinese garbled code resolution
Install Scala on window
Step 1:Java setting
The detection method has been described earlier and will not be described here.
If it is not already installed, you can refer to our Java development environment configuration.
Next, we can download the Scala binary package (bottom of the page) from theScala website address http://www.scala-lang.org/downloads. For this tutorial, we will download version 2.11.7, as shown in the following figure:
After downloading, double-click msi
file, step by step installation, you can use the default installation directory during the installation process.
After installing scala, the system will automatically prompt, click finish to complete the installation.
Right-click my computer and click Properties to go to the page shown in the figure. To configure environment variables, right-click my computer-Properties-Advanced system Settings-Environment variables, as shown below:
Set up SCALA_HOME
variable: click New, and enter: SCALA_HOME
enter the value of the variable in the column: d:Program Files (x86)scala, which is the installation directory of Scala. If you install it on disk C, you can change D to C.
Set up Path
variable: find the “Path” under the system variable as shown in the figure, and click Edit. Add the following path at the front of the variable value column: %SCALA_HOME%\bin;%SCALA_HOME%\jre\bin;
Note: follow the semicolon; don’t leave it out.
Set up Classpath
variable: find the “Classpath” under the system variable as shown in the figure, and click Edit. If not, click “New”:
“variable name”: ClassPath
“variable value”:.;%SCALA_HOME%bin;%SCALA_HOME%libdt.jar;%SCALA_HOME%libtools.jar.;
Note: the one in front of the “variable value”; don’t miss it. Finally, click OK.
Check that the environment variable is set: call up the “cmd” check. Click[start], type cmd in the input box, then enter “enter”, type scala, and then enter, such as setting the environment variable ok, you should be able to see this information.
The following lists the directories placed by different systems (for reference):
System environment |
Variable |
Value (for example) |
---|---|---|
Unix |
|
|
|
|
|
Windows |
|
|
|
|