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.
{% tab Other for=install-scala-project-os defaultTab %}
123
+
<noscript>
124
+
<p><span style="font-style:italic;">JavaScript is disabled, click the tab relevant for your OS.</span></p>
125
+
</noscript>
126
+
Follow [the documentation on Scala CLI's website](https://scala-cli.virtuslab.org/install) for more install options.
127
+
{% endtab %}
128
+
<!-- end Other -->
129
+
130
+
{% endtabs %}
131
+
<!-- End tabs for each OS -->
132
+
133
+
We recommend committing a scala executable for each OS together with your code so that
134
+
everyone working on your project can compile and run the code without needing to install anything (not even Java).
147
135
148
136
## Using the Scala CLI
149
137
150
-
In a directory of your choice, which we will call `<project-dir>`, create a file named `hello.scala` with the following code:
138
+
This section assumes you installed the Scala CLI on your computer. If you installed the Scala CLI in your project
139
+
directory only, you should run the following commands with `./scala` instead of `scala`.
140
+
141
+
In your project directory, which we will call `<project-dir>`, create a file named `hello.scala` with the following code:
151
142
```scala
152
143
//> using scala {{site.scala-3-version}}
153
144
@@ -202,7 +193,7 @@ We use the [os-lib](https://github.com/com-lihaoyi/os-lib) library from the [Sca
202
193
for that purpose. A dependency on the library can be added with the `//> using` directive. Put the following code in `counter.scala`.
203
194
```scala
204
195
//> using scala {{site.scala-3-version}}
205
-
//>usingdep"com.lihaoyi::os-lib:0.10.7"
196
+
//> using dep "com.lihaoyi::os-lib:0.11.4"
206
197
207
198
@main
208
199
def countFiles(): Unit =
@@ -250,7 +241,7 @@ Type in expressions for evaluation. Or try :help.
250
241
scala>
251
242
```
252
243
253
-
Write a line of code to be executed and press enter.
244
+
Write a line of code to be executed and press enter:
254
245
```
255
246
scala> println("Hello, World!")
256
247
Hello, World!
@@ -266,7 +257,7 @@ val i: Int = 1
266
257
scala>
267
258
```
268
259
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.
260
+
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