YouTip LogoYouTip

Scala Install

Scala Installation and Environment Setup | Tutorial\\n\\nScala can run on Windows, Linux, Unix, Mac OS X, and other systems.\\n\\nScala is built on top of Java and extensively uses Java's class libraries and variables. Before using Scala, you must install Java (version > 1.5).\\n\\n* * *\\n\\n## Installing Scala on Mac OS X and Linux\\n\\n### Step 1: Java Setup\\n\\nEnsure that you have installed JDK 1.5 or above locally, and set the JAVA_HOME environment variable and the JDK bin directory.\\n\\nWe can use the following command to check if Java is installed:\\n\\n$ 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) $\\nNext, we can check if the Java compiler is installed. Enter the following command to check:\\n\\n$ javac -version javac 1.8.0_31 $\\nIf it is not installed yet, you can refer to our (#).\\n\\nTo install Scala, it is recommended to use the Scala installer powered by Coursier: cs setup\\n\\nInstall on macOS using the brew command:\\n\\nbrew install coursier/formulas/coursier && cs setup\\nOn Linux, use the curl command to download the source package for installation.\\n\\nx86-64 architecture:\\n\\ncurl -fL https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-linux.gz | gzip -d > cs && chmod +x cs && ./cs setup\\nARM64 architecture:\\n\\ncurl -fL https://github.com/VirtusLab/coursier-m1/releases/latest/download/cs-aarch64-pc-linux.gz | gzip -d > cs && chmod +x cs && ./cs setup\\n> You can check your server's CPU architecture using the uname -m command:\\n> \\n> # uname -m x86_64\\n\\n### Binary Package Installation\\n\\nWe can download the Scala binary package from the Github address [https://github.com/lampepfl/dotty/tags](https://github.com/lampepfl/dotty/tags). In this tutorial, we will download version _2.11.7_, as shown in the figure below:\\n\\n!(#)\\n\\nClick the version number we want to download, then scroll to the bottom of the page to see the download file package:\\n\\n!(#)\\n\\nExtract the file package, and you can move it to /usr/local/share:\\n\\nmv scala-2.11.7 scala # Rename the Scala directory mv /download/scalapath /usr/local/share # The download directory needs to be your actual download path\\nModify the environment variables. If you are not an administrator, you can use sudo to gain administrator privileges and modify the profile configuration file:\\n\\nvim /etc/profile or sudo vim /etc/profile\\nAdd the following at the end of the file:\\n\\nexport PATH="$PATH:/usr/local/share/scala/bin"\\n:wq! Save and exit, restart the terminal, and execute the scala command. If the following information is output, the installation is successful:\\n\\n$ 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.\\n> **Note:** During compilation, if there is 1. or sudo vim text, garbled characters may appear. For the solution, see: [Scala 1. or sudo vim Garbled Text Solution](#)\\n\\n* * *\\n\\n## Installing Scala on Windows\\n\\n### Step 1: Java Setup\\n\\nThe detection method has been explained earlier and will not be repeated here.\\n\\nIf it is not installed yet, you can refer to our (#).\\n\\nNext, we can download the Scala binary package from the Scala official website address [http://www.scala-lang.org/downloads](http://www.scala-lang.org/downloads) (at the bottom of the page). In this tutorial, we will download version _2.11.7_, as shown in the figure below:\\n\\n!(#)\\n\\nAfter downloading, double-click the exe file and follow the steps to install. You can use the default installation directory during the installation process.\\n\\nAfter Scala is installed, the system will automatically prompt you. Click finish to complete the installation.\\n\\nRight-click My Computer, click "Properties", and enter the page as shown. Now start configuring the environment variables: Right-click -- -- -- , as shown in the figure:\\n\\n!(#)\\n\\nSet the SCALA_HOME variable: Click New, enter **SCALA_HOME** in the Variable name field: Enter **D:Program Files(x86οΌ‰scala** in the Variable value field, which is the Scala installation directory. This varies depending on your personal situation. If it is installed on the C drive, change D to C.\\n\\n!(#)\\n\\nSet the Path variable: Find "Path" under System variables, as shown in the figure, and click Edit. Add the following path at the very beginning of the "Variable value" field: %SCALA_HOME%bin;%SCALA_HOME%jrebin;\\n\\n**Note:** Do not omit the semicolon **;** at the end.\\n\\n!(#)\\n\\nSet the Classpath variable: Find "Classpath" under System variables, as shown in the figure, and click Edit. If it does not exist, click "New":\\n\\n* "Variable name": ClassPath\\n* "Variable value": .;%SCALA_HOME%bin;%SCALA_HOME%libdt.jar;%SCALA_HOME%libtools.jar.;\\n\\n**Note:** Do not omit the .; at the very beginning of the "Variable value". Finally, click OK.\\n\\n!(#)\\n\\nCheck if the environment variables are set correctly: Open "cmd" to check. Click , type cmd in the input box, then press "Enter", type scala, and press Enter. If the environment variables are set OK, you should see this information.\\n\\n!(#)\\n\\nThe following lists the directories placed on different systems (for reference):\\n\\n| System Environment | Variable | Value (Example) |\\n| --- | --- | --- |\\n| Unix | `$SCALA_HOME` | `/usr/local/share/scala` |\\n| | `$PATH` | `$PATH:$SCALA_HOME/bin` |\\n| Windows | `%SCALA_HOME%` | `c:Progra~1Scala` |\\n| | `%PATH%` | `%PATH%;%SCALA_HOME%bin` |
← Scala Basic SyntaxScala Intro β†’