Skip to content

Commit 02ebbfe

Browse files
committed
Back to two distinct URls (showing the same content)
1 parent 0a9ae31 commit 02ebbfe

File tree

6 files changed

+200
-195
lines changed

6 files changed

+200
-195
lines changed

_data/scala3-doc-nav-header.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
- title: New in Scala 3
55
url: "/scala3/new-in-scala3.html"
66
- title: Getting Started
7-
url: "/getting-started.html"
7+
url: "/scala3/getting-started.html"
88
- title: Scala 3 Book
99
url: "/scala3/book/introduction.html"
1010
- title: Contributing Guide

_getting-started/index.md

Lines changed: 2 additions & 192 deletions
Original file line numberDiff line numberDiff line change
@@ -4,197 +4,7 @@ title: Getting Started
44
partof: getting-started
55
languages: [ja]
66
includeTOC: true
7-
scala3: true
8-
9-
redirect_from:
10-
- "/getting-started.html"
11-
- "/scala3/getting-started.html"
7+
redirect_from: /getting-started.html
128
---
139

14-
## Try Scala without installing anything
15-
16-
To start experimenting with Scala right away, use <a href="https://scastie.scala-lang.org/pEBYc5VMT02wAGaDrfLnyw" target="_blank">“Scastie” in your browser</a>.
17-
_Scastie_ is an online “playground” where you can experiment with Scala examples to see how things work, with access to all Scala compilers and published libraries.
18-
19-
> Note that Scastie supports both Scala 2 and Scala 3, but it defaults
20-
> to Scala 3. If you are looking for a Scala 2 snippet to play with,
21-
> [click here](https://scastie.scala-lang.org/MHc7C9iiTbGfeSAvg8CKAA).
22-
23-
## Install Scala on your computer
24-
25-
Installing Scala means installing various command-line tools such as the Scala compiler and build tools.
26-
We recommend using the Scala installer tool "Coursier" that automatically installs all the requirements, but you can still manually install each tool.
27-
28-
### Using the Scala Installer (recommended way)
29-
30-
The Scala installer is a tool named [Coursier](https://get-coursier.io/docs/cli-overview), whose main command is named `cs`.
31-
It ensures that a JVM and standard Scala tools are installed on your system.
32-
Install it on your system with the following instructions.
33-
34-
<div class="main-download">
35-
<div id="download-step-one">
36-
<p>Follow <a href="https://get-coursier.io/docs/cli-installation.html#native-launcher" target="_blank">the instructions to install the <code>cs</code> launcher</a> then run:</p>
37-
<p><code>$ ./cs setup</code></p>
38-
</div>
39-
</div>
40-
41-
42-
Along with managing JVMs, `cs setup` also installs useful command-line tools:
43-
44-
- A JDK (if you don't have one already)
45-
- The [sbt](https://www.scala-sbt.org/) build tool
46-
- [Ammonite](https://ammonite.io/), an enhanced REPL
47-
- [scalafmt](https://scalameta.org/scalafmt/), the Scala code formatter
48-
- `scalac` (the Scala 2 compiler)
49-
- `scala` (the Scala 2 REPL and script runner).
50-
51-
For more information about `cs`, read
52-
[coursier-cli documentation](https://get-coursier.io/docs/cli-overview).
53-
54-
> Currently, `cs setup` installs the Scala 2 compiler and runner (the `scalac` and
55-
> `scala` commands, respectively). This is usually not an issue because most projects
56-
> use a build tool that works with both Scala 2 and Scala 3.
57-
> Nevertheless, you can install the Scala 3 compiler and runner as command-line tools
58-
> by running the following additional commands:
59-
> ```
60-
> $ cs install scala3-compiler
61-
> $ cs install scala3
62-
> ```
63-
64-
### ...or manually
65-
66-
You only need two tools to compile, run, test, and package a Scala project: Java 8 or 11,
67-
and sbt.
68-
To install them manually:
69-
70-
1. if you don't have Java 8 or 11 installed, download
71-
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),
72-
or [AdoptOpenJDK 8/11](https://adoptopenjdk.net/). Refer to [JDK Compatibility](/overviews/jdk-compatibility/overview.html) for Scala/Java compatibility detail.
73-
1. Install [sbt](https://www.scala-sbt.org/download.html)
74-
75-
## Create a "Hello World" project with sbt
76-
77-
Once you have installed sbt, you are ready to create a Scala project, which
78-
is explained in the following sections.
79-
80-
To create a project, you can either use the command line or an IDE.
81-
If you are familiar with the command line, we recommend that approach.
82-
83-
### Using the command line
84-
85-
sbt is a build tool for Scala. sbt compiles, runs,
86-
and tests your Scala code. (It can also publish libraries and do many other tasks.)
87-
88-
To create a new Scala project with sbt:
89-
90-
1. `cd` to an empty folder.
91-
1. Run the command `sbt new scala/scala3.g8` to create a Scala 3 project, or `sbt new scala/hello-world.g8` to create a Scala 2 project.
92-
This pulls a project template from GitHub.
93-
It will also create a `target` folder, which you can ignore.
94-
1. When prompted, name the application `hello-world`. This will
95-
create a project called "hello-world".
96-
1. Let's take a look at what just got generated:
97-
98-
```
99-
- hello-world
100-
- project (sbt uses this for its own files)
101-
- build.properties
102-
- build.sbt (sbt's build definition file)
103-
- src
104-
- main
105-
- scala (all of your Scala code goes here)
106-
- Main.scala (Entry point of program) <-- this is all we need for now
107-
```
108-
109-
More documentation about sbt can be found in the [Scala Book](/scala3/book/tools-sbt.html) (see [here](/overviews/scala-book/scala-build-tool-sbt.html) for the Scala 2 version)
110-
and in the official sbt [documentation](https://www.scala-sbt.org/1.x/docs/index.html)
111-
112-
### With an IDE
113-
114-
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)
115-
116-
117-
## Open hello-world project
118-
119-
Let's use an IDE to open the project. The most popular ones are IntelliJ and VSCode.
120-
They both offer rich IDE features, but you can still use [many other editors.](https://scalameta.org/metals/docs/editors/overview.html)
121-
122-
### Using IntelliJ
123-
124-
1. Download and install [IntelliJ Community Edition](https://www.jetbrains.com/idea/download/)
125-
1. Install the Scala plugin by following [the instructions on how to install IntelliJ plugins](https://www.jetbrains.com/help/idea/managing-plugins.html)
126-
1. Open the `build.sbt` file then choose *Open as a project*
127-
128-
### Using VSCode with metals
129-
130-
1. Download [VSCode](https://code.visualstudio.com/Download)
131-
1. Install the Metals extension from [the Marketplace](https://marketplace.visualstudio.com/items?itemName=scalameta.metals)
132-
1. Next, open the directory containing a `build.sbt` file (this should be the directory `hello-world` if you followed the previous instructions). When prompted to do so, select *Import build*.
133-
134-
>[Metals](https://scalameta.org/metals) is a “Scala language server” that provides support for writing Scala code in VS Code and other editors like [Atom, Sublime Text, and more](https://scalameta.org/metals/docs/editors/overview.html), using the Language Server Protocol.
135-
>
136-
> Under the hood, Metals communicates with the build tool by using
137-
> the [Build Server Protocol (BSP)](https://build-server-protocol.github.io/). For details on how Metals works, see, [“Write Scala in VS Code, Vim, Emacs, Atom and Sublime Text with Metals”](https://www.scala-lang.org/2019/04/16/metals.html).
138-
139-
### Play with the source code
140-
141-
View these two files in your IDE:
142-
143-
- _build.sbt_
144-
- _src/main/scala/Main.scala_
145-
146-
When you run your project in the next step, the configuration in _build.sbt_ will be used to run the code in _src/main/scala/Main.scala_.
147-
148-
## Run Hello World
149-
150-
If you’re comfortable using your IDE, you can run the code in _Main.scala_ from your IDE.
151-
152-
Otherwise, you can run the application from a terminal with these steps:
153-
154-
1. `cd` into `hello-world`.
155-
1. Run `sbt`. This opens up the sbt console.
156-
1. Type `~run`. The `~` is optional and causes sbt to re-run on every file save,
157-
allowing for a fast edit/run/debug cycle. sbt will also generate a `target` directory
158-
which you can ignore.
159-
160-
When you’re finished experimenting with this project, press `[Enter]` to interrupt the `run` command.
161-
Then type `exit` or press `[Ctrl+D]` to exit sbt and return to your command line prompt.
162-
163-
## Next Steps
164-
165-
Once you've finished the above tutorials, consider checking out:
166-
167-
* [The Scala Book](/scala3/book/introduction.html) (see the Scala 2 version [here](/overviews/scala-book/introduction.html)), which provides a set of short lessons introducing Scala’s main features.
168-
* [The Tour of Scala](/tour/tour-of-scala.html) for bite-sized introductions to Scala's features.
169-
* [Learning Resources](/learn.html), which includes online interactive tutorials and courses.
170-
* [Our list of some popular Scala books](/books.html).
171-
* [The migration guide](/scala3/guides/migration/compatibility-intro.html) helps you to migrate your existing Scala 2 code base to Scala 3.
172-
173-
## Getting Help
174-
There are a multitude of mailing lists and real-time chat rooms 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.
175-
176-
<!-- Hidden elements whose content are used to provide OS-specific download instructions.
177-
-- This is handled in `resources/js/functions.js`.
178-
-->
179-
<div style="display:none" id="stepOne-linux">
180-
<code class="hljs">$ curl -fLo cs https://git.io/coursier-cli-linux && chmod +x cs && ./cs setup </code> <br>
181-
</div>
182-
183-
<div style="display:none" id="stepOne-unix">
184-
<p>Follow <a href="https://get-coursier.io/docs/cli-installation" target="_blank">the instructions to install the <code>cs</code> launcher</a> then run:</p>
185-
<p><code>$ ./cs setup</code></p>
186-
</div>
187-
188-
<div style="display:none" id="stepOne-osx">
189-
<div class="highlight">
190-
<code class="hljs">$ brew install coursier/formulas/coursier && cs setup </code> <br>
191-
</div>
192-
<p>Alternatively, if you don't use Homebrew</p>
193-
<div class="highlight">
194-
<code class="hljs">$ curl -fLo cs https://git.io/coursier-cli-macos && chmod +x cs && (xattr -d com.apple.quarantine cs || true) && ./cs setup</code> <br>
195-
</div>
196-
</div>
197-
198-
<div style="display:none" id="stepOne-windows">
199-
<p>Download and execute <a href="https://git.io/coursier-cli-windows-exe">the Scala installer for Windows</a> based on coursier</p>
200-
</div>
10+
{% include getting-started.md %}

_includes/getting-started.md

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
## Try Scala without installing anything
2+
3+
To start experimenting with Scala right away, use <a href="https://scastie.scala-lang.org/pEBYc5VMT02wAGaDrfLnyw" target="_blank">“Scastie” in your browser</a>.
4+
_Scastie_ is an online “playground” where you can experiment with Scala examples to see how things work, with access to all Scala compilers and published libraries.
5+
6+
> Note that Scastie supports both Scala 2 and Scala 3, but it defaults
7+
> to Scala 3. If you are looking for a Scala 2 snippet to play with,
8+
> [click here](https://scastie.scala-lang.org/MHc7C9iiTbGfeSAvg8CKAA).
9+
10+
## Install Scala on your computer
11+
12+
Installing Scala means installing various command-line tools such as the Scala compiler and build tools.
13+
We recommend using the Scala installer tool "Coursier" that automatically installs all the requirements, but you can still manually install each tool.
14+
15+
### Using the Scala Installer (recommended way)
16+
17+
The Scala installer is a tool named [Coursier](https://get-coursier.io/docs/cli-overview), whose main command is named `cs`.
18+
It ensures that a JVM and standard Scala tools are installed on your system.
19+
Install it on your system with the following instructions.
20+
21+
<div class="main-download">
22+
<div id="download-step-one">
23+
<p>Follow <a href="https://get-coursier.io/docs/cli-installation.html#native-launcher" target="_blank">the instructions to install the <code>cs</code> launcher</a> then run:</p>
24+
<p><code>$ ./cs setup</code></p>
25+
</div>
26+
</div>
27+
28+
29+
Along with managing JVMs, `cs setup` also installs useful command-line tools:
30+
31+
- A JDK (if you don't have one already)
32+
- The [sbt](https://www.scala-sbt.org/) build tool
33+
- [Ammonite](https://ammonite.io/), an enhanced REPL
34+
- [scalafmt](https://scalameta.org/scalafmt/), the Scala code formatter
35+
- `scalac` (the Scala 2 compiler)
36+
- `scala` (the Scala 2 REPL and script runner).
37+
38+
For more information about `cs`, read
39+
[coursier-cli documentation](https://get-coursier.io/docs/cli-overview).
40+
41+
> Currently, `cs setup` installs the Scala 2 compiler and runner (the `scalac` and
42+
> `scala` commands, respectively). This is usually not an issue because most projects
43+
> use a build tool that works with both Scala 2 and Scala 3.
44+
> Nevertheless, you can install the Scala 3 compiler and runner as command-line tools
45+
> by running the following additional commands:
46+
> ```
47+
> $ cs install scala3-compiler
48+
> $ cs install scala3
49+
> ```
50+
51+
### ...or manually
52+
53+
You only need two tools to compile, run, test, and package a Scala project: Java 8 or 11,
54+
and sbt.
55+
To install them manually:
56+
57+
1. if you don't have Java 8 or 11 installed, download
58+
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),
59+
or [AdoptOpenJDK 8/11](https://adoptopenjdk.net/). Refer to [JDK Compatibility](/overviews/jdk-compatibility/overview.html) for Scala/Java compatibility detail.
60+
1. Install [sbt](https://www.scala-sbt.org/download.html)
61+
62+
## Create a "Hello World" project with sbt
63+
64+
Once you have installed sbt, you are ready to create a Scala project, which
65+
is explained in the following sections.
66+
67+
To create a project, you can either use the command line or an IDE.
68+
If you are familiar with the command line, we recommend that approach.
69+
70+
### Using the command line
71+
72+
sbt is a build tool for Scala. sbt compiles, runs,
73+
and tests your Scala code. (It can also publish libraries and do many other tasks.)
74+
75+
To create a new Scala project with sbt:
76+
77+
1. `cd` to an empty folder.
78+
1. Run the command `sbt new scala/scala3.g8` to create a Scala 3 project, or `sbt new scala/hello-world.g8` to create a Scala 2 project.
79+
This pulls a project template from GitHub.
80+
It will also create a `target` folder, which you can ignore.
81+
1. When prompted, name the application `hello-world`. This will
82+
create a project called "hello-world".
83+
1. Let's take a look at what just got generated:
84+
85+
```
86+
- hello-world
87+
- project (sbt uses this for its own files)
88+
- build.properties
89+
- build.sbt (sbt's build definition file)
90+
- src
91+
- main
92+
- scala (all of your Scala code goes here)
93+
- Main.scala (Entry point of program) <-- this is all we need for now
94+
```
95+
96+
More documentation about sbt can be found in the [Scala Book](/scala3/book/tools-sbt.html) (see [here](/overviews/scala-book/scala-build-tool-sbt.html) for the Scala 2 version)
97+
and in the official sbt [documentation](https://www.scala-sbt.org/1.x/docs/index.html)
98+
99+
### With an IDE
100+
101+
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)
102+
103+
104+
## Open hello-world project
105+
106+
Let's use an IDE to open the project. The most popular ones are IntelliJ and VSCode.
107+
They both offer rich IDE features, but you can still use [many other editors.](https://scalameta.org/metals/docs/editors/overview.html)
108+
109+
### Using IntelliJ
110+
111+
1. Download and install [IntelliJ Community Edition](https://www.jetbrains.com/idea/download/)
112+
1. Install the Scala plugin by following [the instructions on how to install IntelliJ plugins](https://www.jetbrains.com/help/idea/managing-plugins.html)
113+
1. Open the `build.sbt` file then choose *Open as a project*
114+
115+
### Using VSCode with metals
116+
117+
1. Download [VSCode](https://code.visualstudio.com/Download)
118+
1. Install the Metals extension from [the Marketplace](https://marketplace.visualstudio.com/items?itemName=scalameta.metals)
119+
1. Next, open the directory containing a `build.sbt` file (this should be the directory `hello-world` if you followed the previous instructions). When prompted to do so, select *Import build*.
120+
121+
>[Metals](https://scalameta.org/metals) is a “Scala language server” that provides support for writing Scala code in VS Code and other editors like [Atom, Sublime Text, and more](https://scalameta.org/metals/docs/editors/overview.html), using the Language Server Protocol.
122+
>
123+
> Under the hood, Metals communicates with the build tool by using
124+
> the [Build Server Protocol (BSP)](https://build-server-protocol.github.io/). For details on how Metals works, see, [“Write Scala in VS Code, Vim, Emacs, Atom and Sublime Text with Metals”](https://www.scala-lang.org/2019/04/16/metals.html).
125+
126+
### Play with the source code
127+
128+
View these two files in your IDE:
129+
130+
- _build.sbt_
131+
- _src/main/scala/Main.scala_
132+
133+
When you run your project in the next step, the configuration in _build.sbt_ will be used to run the code in _src/main/scala/Main.scala_.
134+
135+
## Run Hello World
136+
137+
If you’re comfortable using your IDE, you can run the code in _Main.scala_ from your IDE.
138+
139+
Otherwise, you can run the application from a terminal with these steps:
140+
141+
1. `cd` into `hello-world`.
142+
1. Run `sbt`. This opens up the sbt console.
143+
1. Type `~run`. The `~` is optional and causes sbt to re-run on every file save,
144+
allowing for a fast edit/run/debug cycle. sbt will also generate a `target` directory
145+
which you can ignore.
146+
147+
When you’re finished experimenting with this project, press `[Enter]` to interrupt the `run` command.
148+
Then type `exit` or press `[Ctrl+D]` to exit sbt and return to your command line prompt.
149+
150+
## Next Steps
151+
152+
Once you've finished the above tutorials, consider checking out:
153+
154+
* [The Scala Book](/scala3/book/introduction.html) (see the Scala 2 version [here](/overviews/scala-book/introduction.html)), which provides a set of short lessons introducing Scala’s main features.
155+
* [The Tour of Scala](/tour/tour-of-scala.html) for bite-sized introductions to Scala's features.
156+
* [Learning Resources](/learn.html), which includes online interactive tutorials and courses.
157+
* [Our list of some popular Scala books](/books.html).
158+
* [The migration guide](/scala3/guides/migration/compatibility-intro.html) helps you to migrate your existing Scala 2 code base to Scala 3.
159+
160+
## Getting Help
161+
There are a multitude of mailing lists and real-time chat rooms 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.
162+
163+
<!-- Hidden elements whose content are used to provide OS-specific download instructions.
164+
-- This is handled in `resources/js/functions.js`.
165+
-->
166+
<div style="display:none" id="stepOne-linux">
167+
<code class="hljs">$ curl -fLo cs https://git.io/coursier-cli-linux && chmod +x cs && ./cs setup </code> <br>
168+
</div>
169+
170+
<div style="display:none" id="stepOne-unix">
171+
<p>Follow <a href="https://get-coursier.io/docs/cli-installation" target="_blank">the instructions to install the <code>cs</code> launcher</a> then run:</p>
172+
<p><code>$ ./cs setup</code></p>
173+
</div>
174+
175+
<div style="display:none" id="stepOne-osx">
176+
<div class="highlight">
177+
<code class="hljs">$ brew install coursier/formulas/coursier && cs setup </code> <br>
178+
</div>
179+
<p>Alternatively, if you don't use Homebrew</p>
180+
<div class="highlight">
181+
<code class="hljs">$ curl -fLo cs https://git.io/coursier-cli-macos && chmod +x cs && (xattr -d com.apple.quarantine cs || true) && ./cs setup</code> <br>
182+
</div>
183+
</div>
184+
185+
<div style="display:none" id="stepOne-windows">
186+
<p>Download and execute <a href="https://git.io/coursier-cli-windows-exe">the Scala installer for Windows</a> based on coursier</p>
187+
</div>

0 commit comments

Comments
 (0)