You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Run the following command in your terminal, following the on-screen instructions:
99
+
{% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macos-linux-launcher-cli %}
100
+
{% endtab %}
101
+
<!-- end macOS/Linux -->
102
+
103
+
<!-- Windows -->
104
+
{% tab Windows for=install-scala-project-os %}
105
+
{% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.windows-launcher-cli %}
106
+
{% endtab %}
107
+
<!-- end Windows -->
108
+
109
+
<!-- Other -->
110
+
{% tab Other for=install-scala-project-os defaultTab %}
111
+
<noscript>
112
+
<p><spanstyle="font-style:italic;">JavaScript is disabled, click the tab relevant for your OS.</span></p>
113
+
</noscript>
114
+
Follow [the documentation on Scala CLI's website](https://scala-cli.virtuslab.org/install) for more install options.
115
+
{% endtab %}
116
+
<!-- end Other -->
117
+
118
+
{% endtabs %}
119
+
<!-- End tabs for each OS -->
120
+
121
+
We recommend committing a scala executable for each OS together with your code so that
122
+
everyone working on your project can compile and run the code without needing to install anything (not even Java).
147
123
148
124
## Using the Scala CLI
149
125
150
-
In a directory of your choice, which we will call `<project-dir>`, create a file named `hello.scala` with the following code:
126
+
This section assumes you installed the Scala CLI on your computer. If you installed the Scala CLI in your project
127
+
directory only, you should run the following commands with `./scala` instead of `scala`.
128
+
129
+
In your project directory, which we will call `<project-dir>`, create a file named `hello.scala` with the following code:
151
130
```scala
152
131
//>usingscala{{site.scala-3-version}}
153
132
@@ -202,7 +181,7 @@ We use the [os-lib](https://github.com/com-lihaoyi/os-lib) library from the [Sca
202
181
for that purpose. A dependency on the library can be added with the `//> using` directive. Put the following code in `counter.scala`.
203
182
```scala
204
183
//>usingscala{{site.scala-3-version}}
205
-
//>usingdep"com.lihaoyi::os-lib:0.10.7"
184
+
//>usingdep"com.lihaoyi::os-lib:0.11.4"
206
185
207
186
@main
208
187
defcountFiles():Unit=
@@ -250,7 +229,7 @@ Type in expressions for evaluation. Or try :help.
250
229
scala>
251
230
```
252
231
253
-
Write a line of code to be executed and press enter.
232
+
Write a line of code to be executed and press enter:
254
233
```
255
234
scala> println("Hello, World!")
256
235
Hello, World!
@@ -266,7 +245,7 @@ val i: Int = 1
266
245
scala>
267
246
```
268
247
269
-
A new value of type `Int` has been created. If you provide an expression that can be evaluated, its result will be stored in an automatically created value.
248
+
A new value of type `Int` has been created. If you provide an expression that can be evaluated, its result will be stored in an automatically created value:
0 commit comments