@@ -33,48 +33,25 @@ The instructions below cover both Scala 2 and Scala 3.
33
33
34
34
{% include inner-documentation-sections.html links=page.newcomer_resources %}
35
35
36
- ## Install Scala on your computer
36
+ ## Install the Scala CLI
37
37
38
- Installing Scala means installing various command-line tools such as the Scala compiler and build tools.
39
- We recommend using the Scala installer tool "Coursier" that automatically installs all the requirements, but you can still manually install each tool.
38
+ ### Install Scala in your project
40
39
41
- ### Using the Scala Installer (recommended way)
42
-
43
- The Scala installer is a tool named [ Coursier] ( https://get-coursier.io/docs/cli-overview ) , whose main command is named ` cs ` .
44
- It ensures that a JVM and standard Scala tools are installed on your system.
45
- Install it on your system with the following instructions.
40
+ Download the Scala CLI launcher in your project directory:
46
41
47
42
<!-- Display tabs for each OS -->
48
43
{% tabs install-cs-setup-tabs class=platform-os-options %}
49
44
50
- <!-- macOS -->
51
- {% tab macOS for=install-cs-setup-tabs %}
45
+ <!-- macOS/Linux -->
46
+ {% tab macOS/Linux for=install-cs-setup-tabs %}
52
47
Run the following command in your terminal, following the on-screen instructions:
53
- {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-brew %}
54
- {% altDetails cs-setup-macos-nobrew "Alternatively, if you don't use Homebrew:" %}
55
- On the Apple Silicon (M1, M2, …) architecture:
56
- {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-arm64 %}
57
- Otherwise, on the x86-64 architecture:
58
- {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-x86-64 %}
59
- {% endaltDetails %}
60
- {% endtab %}
61
- <!-- end macOS -->
62
-
63
- <!-- Linux -->
64
- {% tab Linux for=install-cs-setup-tabs %}
65
- Run the following command in your terminal, following the on-screen instructions.
66
-
67
- On the x86-64 architecture:
68
- {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.linux-x86-64 %}
69
- Otherwise, on the ARM64 architecture:
70
- {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.linux-arm64 %}
48
+ {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macos-linux-cli %}
71
49
{% endtab %}
72
- <!-- end Linux -->
50
+ <!-- end macOS/ Linux -->
73
51
74
52
<!-- Windows -->
75
53
{% tab Windows for=install-cs-setup-tabs %}
76
- Download and execute [ the Scala installer for Windows] ( {{site.data.setup-scala.windows-link}} )
77
- based on Coursier, and follow the on-screen instructions.
54
+ {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.windows-cli %}
78
55
{% endtab %}
79
56
<!-- end Windows -->
80
57
@@ -83,67 +60,21 @@ Run the following command in your terminal, following the on-screen instructions
83
60
<noscript >
84
61
<p><span style="font-style:italic;">JavaScript is disabled, click the tab relevant for your OS.</span></p>
85
62
</noscript >
86
- Follow the documentation from Coursier on
87
- [ how to install and run ` cs setup ` ] ( https://get-coursier.io/docs/cli-installation ) .
63
+ Follow the documentation from the Scala CLI on
64
+ [ how to install and run ` scala ` ] ( https://scala-cli.virtuslab.org/install ) .
88
65
{% endtab %}
89
66
<!-- end Other -->
90
67
91
68
{% endtabs %}
92
69
<!-- End tabs -->
93
70
94
- > <i class =" fa fa-info " ></i >  ;  ; You may need to restart your terminal, log out,
95
- > or reboot in order for the changes to take effect.
96
- {: .help-info}
97
-
98
- <!-- Alternative Detail - test the `scala` command -->
99
- {% altDetails testing-your-setup 'Testing your setup' %}
100
- Check your setup with the command ` scala -version ` , which should output:
101
- ``` bash
102
- $ scala -version
103
- Scala code runner version: 1.4.3
104
- Scala version (default): {{site.scala-3-version}}
105
- ```
106
- {% endaltDetails %}
107
- <!-- end Alternative Detail -->
108
-
109
-
110
- Along with managing JVMs, ` cs setup ` also installs useful command-line tools:
111
-
112
- | Commands | Description |
113
- | ----------| -------------|
114
- | ` scalac ` | the Scala compiler |
115
- | ` scala ` , ` scala-cli ` | [ Scala CLI] ( https://scala-cli.virtuslab.org ) , interactive toolkit for Scala |
116
- | ` sbt ` , ` sbtn ` | The [ sbt] ( https://www.scala-sbt.org/ ) build tool |
117
- | ` amm ` | [ Ammonite] ( https://ammonite.io/ ) is an enhanced REPL |
118
- | ` scalafmt ` | [ Scalafmt] ( https://scalameta.org/scalafmt/ ) is the Scala code formatter |
119
-
120
- For more information about ` cs ` , read
121
- [ coursier-cli documentation] ( https://get-coursier.io/docs/cli-overview ) .
122
-
123
- > ` cs setup ` installs the Scala 3 compiler and runner by default (the ` scalac ` and
124
- > ` scala ` commands, respectively). Whether you intend to use Scala 2 or 3,
125
- > this is usually not an issue because most projects use a build tool that will
126
- > use the correct version of Scala irrespective of the one installed "globally".
127
- > Nevertheless, you can always launch a specific version of Scala using
128
- > ```
129
- > $ cs launch scala:{{ site.scala-version }}
130
- > $ cs launch scalac:{{ site.scala-version }}
131
- > ```
132
- > If you prefer Scala 2 to be run by default, you can force that version to be installed with:
133
- > ```
134
- > $ cs install scala:{{ site.scala-version }} scalac:{{ site.scala-version }}
135
- > ```
136
-
137
- ### ...or manually
138
-
139
- You only need two tools to compile, run, test, and package a Scala project: Java 8 or 11,
140
- and Scala CLI.
141
- To install them manually:
142
-
143
- 1. if you don't have Java 8 or 11 installed, download
144
- Java from [Oracle Java 8](https://www.oracle.com/java/technologies/javase-jdk8-downloads.html), [Oracle Java 11](https://www.oracle.com/java/technologies/javase-jdk11-downloads.html),
145
- or [AdoptOpenJDK 8/11](https://adoptopenjdk.net/). Refer to [JDK Compatibility](/overviews/jdk-compatibility/overview.html) for Scala/Java compatibility detail.
146
- 1. Install [Scala CLI](https://scala-cli.virtuslab.org/install)
71
+ We recommend committing the scala executable together with your code so that
72
+ everyone working on the project can compile and run the code without needing to install anything (not even Java).
73
+
74
+ ### ...or/and install Scala on your computer
75
+
76
+ Follow the documentation from the Scala CLI on
77
+ [ how to install and run ` scala ` ] ( https://scala-cli.virtuslab.org/install ) .
147
78
148
79
## Using the Scala CLI
149
80
@@ -164,7 +95,7 @@ string to standard output.
164
95
To run the program, execute ` scala run hello.scala ` command from a terminal, within the ` <project-dir> ` directory. The file will be compiled and executed, with console output
165
96
similar to following:
166
97
```
167
- $ scala run hello.scala
98
+ $ ./ scala run hello.scala
168
99
Compiling project (Scala {{site.scala-3-version}}, JVM (20))
169
100
Compiled project (Scala {{site.scala-3-version}}, JVM (20))
170
101
Hello, World!
@@ -187,7 +118,7 @@ the content of the `name` argument.
187
118
188
119
To pass the arguments when executing the program, put them after ` -- ` :
189
120
```
190
- $ scala run hello.scala -- Gabriel
121
+ $ ./ scala run hello.scala -- Gabriel
191
122
Compiling project (Scala {{site.scala-3-version}}, JVM (20))
192
123
Compiled project (Scala {{site.scala-3-version}}, JVM (20))
193
124
Hello, Gabriel!
@@ -216,7 +147,7 @@ sequence of paths.
216
147
217
148
Execute the program. The dependency will be automatically downloaded. The execution should result in a similar output:
218
149
```
219
- $ scala run counter.scala
150
+ $ ./ scala run counter.scala
220
151
Compiling project (Scala {{site.scala-3-version}}, JVM (20))
221
152
Compiled project (Scala {{site.scala-3-version}}, JVM (20))
222
153
4
@@ -243,7 +174,7 @@ This program is identical to the one above. However, other toolkit libraries wil
243
174
244
175
You can execute code interactively using the REPL provided by the ` scala ` command. Execute ` scala ` in the console without any arguments.
245
176
```
246
- $ scala
177
+ $ ./ scala
247
178
Welcome to Scala {{site.scala-3-version}} (20-ea, Java OpenJDK 64-Bit Server VM).
248
179
Type in expressions for evaluation. Or try :help.
249
180
0 commit comments