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
* making the page self contained: users can have a working "hello-world"
without visiting other pages
* introducing couriser-cli a recommended way to install jvm requirements
* adding Vscode/metals as a possible IDE
* advertising only two ways of starting with Scala: interactive with Scastie or with and IDE + sbt
You can [try Scala in your browser](https://scastie.scala-lang.org/MHc7C9iiTbGfeSAvg8CKAA), with access to all Scala compilers and
12
+
all published libraries.
13
+
14
+
## Installing Scala
15
+
### Using the Scala Installer (recommended way)
16
+
The Scala installer is a tool named `cs` that ensures that a JVM and standard Scala tools are installed on your system.
17
+
18
+
* Download the `cs` tool and execute the `setup` command
19
+
20
+
<divclass="main-download">
21
+
<div id="download-step-one">
22
+
<p>Follow <a href="https://get-coursier.io/docs/cli-overview.html#install-native-launcher" target="_blank">the instructions to install the <code>cs</code> launcher</a> then run:</p>
23
+
<p><code>$ ./cs setup</code></p>
24
+
</div>
25
+
</div>
26
+
27
+
28
+
Along with managing JVMs, it also install useful command-line tools:
or [AdoptOpenJDK 8/11](https://adoptopenjdk.net/). Refer [JDK Compatibility](/overviews/jdk-compatibility/overview.html) for Scala/Java compatibility detail.
sbt is a build tool for Scala. sbt compiles, runs,
44
+
and tests your projects among other related tasks.
45
+
46
+
1.`cd` to an empty folder.
47
+
1. Run the following command `sbt new scala/hello-world.g8`.
48
+
This pulls the 'hello-world' template from GitHub.
49
+
It will also create a `target` folder, which you can ignore.
50
+
1. When prompted, name the application `hello-world`. This will
51
+
create a project called "hello-world".
52
+
1. Let's take a look at what just got generated:
53
+
54
+
```
55
+
- hello-world
56
+
- project (sbt uses this to install and manage plugins and dependencies)
57
+
- build.properties
58
+
- src
59
+
- main
60
+
- scala (All of your scala code goes here)
61
+
- Main.scala (Entry point of program) <-- this is all we need for now
62
+
- build.sbt (sbt's build definition file)
63
+
```
64
+
65
+
More documentation about sbt can be found in the [Scala Book](/overviews/scala-book/scala-build-tool-sbt.html)
66
+
or in the official sbt [documentation](https://www.scala-sbt.org/1.x/docs/index.html)
67
+
68
+
### Without using command-line
69
+
You can skip the rest of this page and go directly to [Building a Scala Project with IntelliJ and sbt](/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.html#next-steps)
70
+
71
+
72
+
## Open hello-world project
73
+
### Using Intellij
74
+
1. Download and install [IntelliJ Community Edition](https://www.jetbrains.com/idea/download/)
75
+
1. Install Scala plugin by following [the instructions on how to install IntelliJ plugins](https://www.jetbrains.com/help/idea/managing-plugins.html)
76
+
1. Open the `build.sbt` file then choose *Open as a project*
1. Install the Metals extension from [the Marketplace](https://marketplace.visualstudio.com/items?itemName=scalameta.metals)
81
+
1. Next, open the directory containing a `build.sbt` file. When prompted to do so, select *Import build*.
82
+
83
+
## Run Hello World
84
+
Open a terminal
85
+
1.`cd` into `hello-world`.
86
+
1. Run `sbt`. This will open up the sbt console.
87
+
1. Type `~run`. The `~` is optional and causes sbt to re-run on every file save,
88
+
allowing for a fast edit/run/debug cycle. sbt will also generate a `target` directory
89
+
which you can ignore.
10
90
11
-
There are __two__ main ways people prefer to work in Scala:
12
-
13
-
* Using an IDE.
14
-
* Using the command line.
15
-
16
-
The following tutorials will walk you through the setup process for whichever way
17
-
you prefer.
18
-
19
-
However, if you just want to jump directly into Scala without installing anything, skip the guides on this page and check out:
20
-
21
-
*[Our interactive introduction to Scala on scala-exercises.com](https://www.scala-exercises.org/scala_tutorial/terms_and_types), or
22
-
*[Scastie](https://scastie.scala-lang.org/), Scala in the browser, with access to all Scala compilers and all published libraries!
23
-
24
-
## Setting up and getting started with Scala
25
-
26
-
### If you prefer working in an IDE...
27
-
28
-
IntelliJ is the most commonly-used IDE by Scala developers. In this tutorial,
29
-
we'll walk you through downloading and setting up IntelliJ with the Scala
30
-
plugin, and we'll get you started with your first Scala project, complete with
31
-
unit tests!
32
-
33
-
*[Getting Started with Scala in IntelliJ](/getting-started/intellij-track/getting-started-with-scala-in-intellij.html)
34
-
*[Building a Scala Project with IntelliJ and sbt](/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.html)
35
-
*[Testing Scala in IntelliJ with ScalaTest](/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.html)
36
-
37
-
38
-
### If you prefer working on the command line...
39
-
40
-
If you prefer using a text editor like emacs, Vim, Atom, or Sublime Text, then
41
-
the best way to compile, test, and run Scala code is by using _sbt_, Scala's build
42
-
tool.
43
-
44
-
*[Getting Started with Scala and sbt on the Command Line](/getting-started/sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.html)
45
-
*[Testing Scala with sbt and ScalaTest on the Command Line](/getting-started/sbt-track/testing-scala-with-sbt-on-the-command-line.html)
46
-
47
-
<!-- sbt is the easiest way to ensure that your Scala project is reproducible;
48
-
you specify a Scala version, any libraries you depend on, and sbt takes care of
49
-
the rest, so it's as easy as possible for someone else to compile and run your
50
-
Scala project. -->
51
91
52
92
## Next Steps
53
93
Once you've finished these tutorials, check out:
54
94
55
-
*[The Tour of Scala](/tour/tour-of-scala.html) for bite-sized introductions to Scala's features.
56
95
*[The Scala Book](/overviews/scala-book/introduction.html), which provides a set of short lessons introducing Scala’s main features.
96
+
*[The Tour of Scala](/tour/tour-of-scala.html) for bite-sized introductions to Scala's features.
57
97
*[Learning Resources](/learn.html), which includes online interactive tutorials and courses.
58
98
*[Our list of some popular Scala books](/books.html).
59
99
60
100
## Getting Help
61
101
There are a multitude of mailing lists and real-time chat channels in case you want to quickly connect with other Scala users. Check out our [community](https://scala-lang.org/community/) page for a list of these resources, and for where to reach out for help.
102
+
103
+
<!-- Hidden elements whose content are used to provide OS-specific download instructions.
104
+
-- This is handled in `resources/js/functions.js`.
<p>Follow <a href="https://get-coursier.io/docs/cli-overview.html#install-native-launcher" target="_blank">the instructions to install the <code>cs</code> launcher</a> then run:</p>
0 commit comments