Lightbend Scala Language - Professional

My highlights and comments

"2. Follow https://www.scala-sbt.org/1.x/docs/Setup.html to download and install SBT. Once the installation is complete, verify the installation by running the following command in a terminal session:

$ sbt sbtVersion

[info] Loading global plugins from ...

[info] Set current project to ...

[info] 1.4.6

  • Your sbt version may be different than 1.4.6
" (Section Introduction > Initial Setup > Exercise: Initial Setup)

I ran SBT successfully after installing it:

C:\Users\jaime>sbt sbtVersion
[info] Loading global plugins from C:\Users\jaime\.sbt\1.0\plugins
[info] Loading project definition from C:\Users\jaime\project
[info] Set current project to jaime (in build file:/C:/Users/jaime/)
[info] 1.3.4


Running from IntelliJ IDEA from sbt shell:

"C:\Program Files\Java\jdk1.8.0_261\bin\java.exe" -agentlib:jdwp=transport=dt_socket,address=localhost:93561,suspend=n,server=y -Xdebug -server -Xmx1536M -Dsbt.supershell=false "-Dhttp.nonProxyHosts=local|123.254/16|*.jaimemontoya.com|rqghwhTRF|*.jaimemontoya.com|thwhje|*jaimemontoyalabs.com" -Didea.managed=true -Dfile.encoding=UTF-8 -Dsbt.log.noformat=true -jar C:\Users\dw31i9r\AppData\Roaming\JetBrains\IdeaIC2020.2\plugins\Scala\launcher\sbt-launch.jar early(addPluginSbtFile=\"\"\"C:\Users\dw31i9r\AppData\Local\Temp\idea1.sbt\"\"\") " idea-shell"
Listening for transport dt_socket at address: 93561
[info] Loading settings for project global-plugins from idea1.sbt ...
[info] Loading global plugins from C:\Users\dw31i9r\.sbt\1.0\plugins
[info] Loading project definition from C:\Scala\data-sync\project\project
[info] Loading settings for project data-sync-build from assembly.sbt,plugins.sbt ...
[info] Loading project definition from C:\Scala\data-sync\project
[info] Loading settings for project data-sync from build.sbt,version.sbt ...
[info] Set current project to data-sync (in build file:/C:/Scala/data-sync/)
[IJ]sbt:data-sync> sbtVersion
[info] 1.2.8
[IJ]sbt:data-sync>


I installed JDK, specifically AdoptOpenJDK JDK 11:

C:\Users\jaime>java -version
openjdk version "11.0.9" 2020-10-20
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9+11)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.9+11, mixed mode)

C:\Users\jaime>java -fullversion
openjdk full version "11.0.9+11"

I also installed Oracle JDK:

C:\Users\dw31i9r>java -version
java version "1.8.0_261"
Java(TM) SE Runtime Environment (build 1.8.0_261-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)

C:\Users\dw31i9r>java -fullversion
java full version "1.8.0_261-b12"

This is how I created a simple program using the sbt new command, running it and finally exiting the sbt shell:

Microsoft Windows [Version 10.0.19042.985]
(c) Microsoft Corporation. All rights reserved.

C:\Users\jaime>sbt new sbt/scala-seed.g8
[info] Loading global plugins from C:\Users\jaime\.sbt\1.0\plugins
[info] Loading project definition from C:\Users\jaime\project
[info] Set current project to jaime (in build file:/C:/Users/jaime/)
[info] Set current project to jaime (in build file:/C:/Users/jaime/)

A minimal Scala project.

name [Scala Seed Project]:hello
Template applied in C:\Users\jaime\.\hello


C:\Users\jaime>dir
Volume in drive C is OS
Volume Serial Number is 5AA3-AF22

Directory of C:\Users\jaime

06/12/2021 07:55 PM <DIR> .
06/12/2021 07:55 PM <DIR> ..
11/12/2020 06:07 AM <DIR> .android
05/05/2021 02:08 AM <DIR> .cache
05/05/2021 02:21 PM <DIR> .config
05/05/2021 05:48 PM <DIR> .eclipse
05/05/2021 02:10 PM 65 .gitconfig
11/19/2020 05:55 AM <DIR> .idea-build
11/13/2020 06:01 AM <DIR> .ivy2
05/05/2021 02:08 AM <DIR> .p2
05/21/2021 09:30 AM <DIR> .sbt
05/01/2021 12:51 AM 918 .scala_history
09/25/2020 03:02 PM <DIR> 3D Objects
09/25/2020 03:02 PM <DIR> Contacts
05/15/2021 03:53 PM <DIR> Desktop
05/25/2021 03:14 PM <DIR> Documents
06/11/2021 06:51 PM <DIR> Downloads
06/11/2021 08:39 AM <DIR> Dropbox
05/05/2021 02:05 AM <DIR> eclipse
05/05/2021 02:02 AM <DIR> eclipse-installer
05/05/2021 07:08 PM <DIR> eclipse-workspace
09/25/2020 03:02 PM <DIR> Favorites
05/05/2021 07:07 PM <DIR> git
06/12/2021 07:55 PM <DIR> hello
11/12/2020 06:17 AM <DIR> IdeaProjects
05/10/2021 01:01 PM <DIR> intellij-workspace
09/25/2020 03:02 PM <DIR> Links
09/25/2020 03:02 PM <DIR> Music
11/06/2020 12:56 AM <DIR> null
06/08/2021 10:17 AM <DIR> OneDrive
09/25/2020 03:18 PM <DIR> Pictures
11/06/2020 12:56 AM <DIR> project
09/25/2020 03:02 PM <DIR> Saved Games
09/25/2020 03:03 PM <DIR> Searches
04/27/2021 02:56 AM <DIR> target
09/26/2020 03:47 AM <DIR> Videos
 2 File(s) 983 bytes
34 Dir(s) 258,539,397,120 bytes free

C:\Users\jaime>cd hello

C:\Users\jaime\hello>dir
Volume in drive C is OS
Volume Serial Number is 5AA3-AF22

Directory of C:\Users\jaime\hello

06/12/2021 07:55 PM <DIR> .
06/12/2021 07:55 PM <DIR> ..
06/12/2021 07:55 PM 1,462 build.sbt
06/12/2021 07:55 PM <DIR> project
06/12/2021 07:55 PM <DIR> src
1 File(s) 1,462 bytes
4 Dir(s) 258,539,327,488 bytes free

C:\Users\jaime\hello>sbt
[info] [launcher] getting org.scala-sbt sbt 1.2.7 (this may take some time)...
downloading https://repo1.maven.org/maven2/org/scala-sbt/command_2.12/1.2.7/command_2.12-1.2.7.jar ...
downloading https://repo1.maven.org/maven2/org/scala-sbt/main_2.12/1.2.7/main_2.12-1.2.7.jar ...
downloading https://repo1.maven.org/maven2/org/scala-sbt/main-settings_2.12/1.2.7/main-settings_2.12-1.2.7.jar ...
downloading https://repo1.maven.org/maven2/org/scala-sbt/actions_2.12/1.2.7/actions_2.12-1.2.7.jar ...
downloading https://repo1.maven.org/maven2/org/scala-sbt/run_2.12/1.2.7/run_2.12-1.2.7.jar ...
downloading https://repo1.maven.org/maven2/org/scala-sbt/sbt/1.2.7/sbt-1.2.7.jar ...
downloading https://repo1.maven.org/maven2/org/scala-sbt/logic_2.12/1.2.7/logic_2.12-1.2.7.jar ...
:: loading settings :: url = jar:file:/C:/Program%20Files%20(x86)/sbt/bin/sbt-launch.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: loading settings :: url = jar:file:/C:/Program%20Files%20(x86)/sbt/bin/sbt-launch.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: loading settings :: url = jar:file:/C:/Program%20Files%20(x86)/sbt/bin/sbt-launch.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: loading settings :: url = jar:file:/C:/Program%20Files%20(x86)/sbt/bin/sbt-launch.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: loading settings :: url = jar:file:/C:/Program%20Files%20(x86)/sbt/bin/sbt-launch.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: loading settings :: url = jar:file:/C:/Program%20Files%20(x86)/sbt/bin/sbt-launch.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: loading settings :: url = jar:file:/C:/Program%20Files%20(x86)/sbt/bin/sbt-launch.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: loading settings :: url = jar:file:/C:/Program%20Files%20(x86)/sbt/bin/sbt-launch.jar!/org/apache/ivy/core/settings/ivysettings.xml
downloading https://repo1.maven.org/maven2/org/scala-sbt/collections_2.12/1.2.7/collections_2.12-1.2.7.jar ...
[SUCCESSFUL ] org.scala-sbt#run_2.12;1.2.7!run_2.12.jar (255ms)
downloading https://repo1.maven.org/maven2/org/scala-sbt/scripted-sbt-redux_2.12/1.2.7/scripted-sbt-redux_2.12-1.2.7.jar ...
[SUCCESSFUL ] org.scala-sbt#sbt;1.2.7!sbt.jar (397ms)
downloading https://repo1.maven.org/maven2/org/scala-sbt/scripted-plugin_2.12/1.2.7/scripted-plugin_2.12-1.2.7.jar ...
[SUCCESSFUL ] org.scala-sbt#logic_2.12;1.2.7!logic_2.12.jar (407ms)
downloading https://repo1.maven.org/maven2/org/scala-sbt/librarymanagement-core_2.12/1.2.3/librarymanagement-core_2.12-1.2.3.jar ...
[SUCCESSFUL ] org.scala-sbt#actions_2.12;1.2.7!actions_2.12.jar (479ms)
downloading https://repo1.maven.org/maven2/org/scala-sbt/librarymanagement-ivy_2.12/1.2.3/librarymanagement-ivy_2.12-1.2.3.jar ...
[SUCCESSFUL ] org.scala-sbt#scripted-sbt-redux_2.12;1.2.7!scripted-sbt-redux_2.12.jar (380ms)
[SUCCESSFUL ] org.scala-sbt#command_2.12;1.2.7!command_2.12.jar (640ms)
downloading https://repo1.maven.org/maven2/org/scala-sbt/task-system_2.12/1.2.7/task-system_2.12-1.2.7.jar ...
downloading https://repo1.maven.org/maven2/org/scala-sbt/completion_2.12/1.2.7/completion_2.12-1.2.7.jar ...
[SUCCESSFUL ] org.scala-sbt#scripted-plugin_2.12;1.2.7!scripted-plugin_2.12.jar (336ms)
downloading https://repo1.maven.org/maven2/org/scala-sbt/tasks_2.12/1.2.7/tasks_2.12-1.2.7.jar ...
[SUCCESSFUL ] org.scala-sbt#collections_2.12;1.2.7!collections_2.12.jar (1085ms)
downloading https://repo1.maven.org/maven2/org/scala-sbt/testing_2.12/1.2.7/testing_2.12-1.2.7.jar ...
[SUCCESSFUL ] org.scala-sbt#main-settings_2.12;1.2.7!main-settings_2.12.jar (1136ms)
downloading https://repo1.maven.org/maven2/org/scala-sbt/test-agent/1.2.7/test-agent-1.2.7.jar ...
[SUCCESSFUL ] org.scala-sbt#tasks_2.12;1.2.7!tasks_2.12.jar (438ms)
downloading https://repo1.maven.org/maven2/org/scala-sbt/core-macros_2.12/1.2.7/core-macros_2.12-1.2.7.jar ...
[SUCCESSFUL ] org.scala-sbt#librarymanagement-ivy_2.12;1.2.3!librarymanagement-ivy_2.12.jar (713ms)
downloading https://repo1.maven.org/maven2/org/scala-sbt/protocol_2.12/1.2.7/protocol_2.12-1.2.7.jar ...
[SUCCESSFUL ] org.scala-sbt#task-system_2.12;1.2.7!task-system_2.12.jar (624ms)
downloading https://repo1.maven.org/maven2/org/scala-sbt/ivy/ivy/2.3.0-sbt-b18f59ea3bc914a297bb6f1a4f7fb0ace399e310/ivy-2.3.0-sbt-b18f59ea3bc914a297bb6f1a4f7fb0ace399e310.jar ...
[SUCCESSFUL ] org.scala-sbt#completion_2.12;1.2.7!completion_2.12.jar (652ms)
[SUCCESSFUL ] org.scala-sbt#test-agent;1.2.7!test-agent.jar (298ms)
[SUCCESSFUL ] org.scala-sbt#librarymanagement-core_2.12;1.2.3!librarymanagement-core_2.12.jar (1035ms)
[SUCCESSFUL ] org.scala-sbt#core-macros_2.12;1.2.7!core-macros_2.12.jar (352ms)
[SUCCESSFUL ] org.scala-sbt#testing_2.12;1.2.7!testing_2.12.jar (613ms)
[SUCCESSFUL ] org.scala-sbt#protocol_2.12;1.2.7!protocol_2.12.jar (586ms)
[SUCCESSFUL ] org.scala-sbt#main_2.12;1.2.7!main_2.12.jar (1881ms)
[SUCCESSFUL ] org.scala-sbt.ivy#ivy;2.3.0-sbt-b18f59ea3bc914a297bb6f1a4f7fb0ace399e310!ivy.jar (838ms)
:: retrieving :: org.scala-sbt#boot-app
confs: [default]
80 artifacts copied, 0 already retrieved
[info] Loading global plugins from C:\Users\jaime\.sbt\1.0\plugins
[info] Updating ProjectRef(uri("file:/C:/Users/jaime/.sbt/1.0/plugins/"), "global-plugins")...
[info] Done updating.
[info] Loading project definition from C:\Users\jaime\hello\project
[info] Updating ProjectRef(uri("file:/C:/Users/jaime/hello/project/"), "hello-build")...
[info] Done updating.
[info] Compiling 1 Scala source to C:\Users\jaime\hello\project\target\scala-2.12\sbt-1.0\classes ...
[info] Done compiling.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.protobuf.UnsafeUtil (file:/C:/Users/jaime/.sbt/boot/scala-2.12.7/org.scala-sbt/sbt/1.2.7/protobuf-java-3.3.1.jar) to field java.nio.Buffer.address
WARNING: Please consider reporting this to the maintainers of com.google.protobuf.UnsafeUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[info] Loading settings for project root from build.sbt ...
[info] Set current project to hello (in build file:/C:/Users/jaime/hello/)
[info] sbt server started at local:sbt-server-4065b01582736cccedf0
sbt:hello> run
[info] Updating ...
[info] downloading https://repo1.maven.org/maven2/org/scalactic/scalactic_2.12/3.0.5/scalactic_2.12-3.0.5.jar ...
[info] downloading https://repo1.maven.org/maven2/org/scalatest/scalatest_2.12/3.0.5/scalatest_2.12-3.0.5.jar ...
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/scala-library/2.12.8/scala-library-2.12.8.jar ...
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/scala-reflect/2.12.8/scala-reflect-2.12.8.jar ...
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.12.8/scala-compiler-2.12.8.jar ...
[info] [SUCCESSFUL ] org.scalactic#scalactic_2.12;3.0.5!scalactic_2.12.jar(bundle) (2579ms)
[info] [SUCCESSFUL ] org.scala-lang#scala-reflect;2.12.8!scala-reflect.jar (6358ms)
[info] [SUCCESSFUL ] org.scala-lang#scala-library;2.12.8!scala-library.jar (7774ms)
[info] [SUCCESSFUL ] org.scalatest#scalatest_2.12;3.0.5!scalatest_2.12.jar(bundle) (8723ms)
[info] [SUCCESSFUL ] org.scala-lang#scala-compiler;2.12.8!scala-compiler.jar (9549ms)
[info] Done updating.
[info] Compiling 1 Scala source to C:\Users\jaime\hello\target\scala-2.12\classes ...
[info] Non-compiled module 'compiler-bridge_2.12' for Scala 2.12.8. Compiling...
[info] Compilation completed in 7.218s.
[info] Done compiling.
[info] Packaging C:\Users\jaime\hello\target\scala-2.12\hello_2.12-0.1.0-SNAPSHOT.jar ...
[info] Done packaging.
[info] Running example.Hello
hello
[success] Total time: 20 s, completed Jun 12, 2021, 7:57:50 PM
sbt:hello> exit
[info] shutting down server

C:\Users\jaime\hello>

This is the content of C:\Users\jaime\hello\build.sbt:

import Dependencies._

ThisBuild / scalaVersion := "2.12.8"
ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / organization := "com.example"
ThisBuild / organizationName := "example"

lazy val root = (project in file("."))
.settings(
name := "hello",
libraryDependencies += scalaTest % Test
)

// Uncomment the following for publishing to Sonatype.
// See https://www.scala-sbt.org/1.x/docs/Using-Sonatype.html for more detail.

// ThisBuild / description := "Some descripiton about your project."
// ThisBuild / licenses := List("Apache 2" -> new URL("http://www.apache.org/licenses/LICENSE-2.0.txt"))
// ThisBuild / homepage := Some(url("https://github.com/example/project"))
// ThisBuild / scmInfo := Some(
// ScmInfo(
// url("https://github.com/your-account/your-project"),
// "scm:git@github.com:your-account/your-project.git"
// )
// )
// ThisBuild / developers := List(
// Developer(
// id = "Your identifier",
// name = "Your Name",
// email = "your@email",
// url = url("http://your.url")
// )
// )
// ThisBuild / pomIncludeRepository := { _ => false }
// ThisBuild / publishTo := {
// val nexus = "https://oss.sonatype.org/"
// if (isSnapshot.value) Some("snapshots" at nexus + "content/repositories/snapshots")
// else Some("releases" at nexus + "service/local/staging/deploy/maven2")
// }
// ThisBuild / publishMavenStyle := true


This is the content of C:\Users\jaime\hello\src\main\scala\example\Hello.scala:

package example

object Hello extends Greeting with App {
println(greeting)
}

trait Greeting {
lazy val greeting: String = "hello"
}


Created: 2021-06-12 01:24:47 Last updated: 2021-06-13 02:38:58

"Summary of important sbt commands

  • exit - ends the sbt session
  • help - lists the available commands
  • compile - compiles the main sources
  • test:compile - compiles the test and main sources
  • test - runs tests after compiling the test and main sources
  • console - starts the REPL with the project on the classpath
  • run - runs a main class, passing args provided on command line
  • clean - deletes files produced by the build in the target directory
  • reload - reloads the project in the current sbt session
  • sbtVersion - provides the version of sbt" (Section Introduction > Initial Setup > Exercise: Initial Setup)

I used the following sbt commands:

  • exit
sbt:hello> exit
[info] shutting down server

C:\Users\jaime\hello>


  • help
sbt:hello> help

about Displays basic information about sbt and the build.
tasks Lists the tasks defined for the current project.
settings Lists the settings defined for the current project.
reload (Re)loads the current project or changes to plugins project or returns from it.
new Creates a new sbt build.
projects Lists the names of available projects or temporarily adds/removes extra builds to the session.
project Displays the current project or changes to the provided `project`.
set [every] <setting> Evaluates a Setting and applies it to the current project.
session Manipulates session settings. For details, run 'help session'.
inspect [tree|uses|definitions|actual] <key> Prints the value for 'key', the defining scope, delegates, related definitions, and dependencies.
<log-level> Sets the logging level to 'log-level'. Valid levels: debug, info, warn, error
plugins Lists currently available plugins.
--addPluginSbtFile=<file> Adds the given *.sbt file to the plugin build.
last Displays output from a previous command or the output from a specific task.
last-grep Shows lines from the last output for 'key' that match 'pattern'.
lastGrep Shows lines from the last output for 'key' that match 'pattern'.
export <tasks>+ Executes tasks and displays the equivalent command lines.
show <key> Displays the result of evaluating the setting or task associated with 'key'.
all <task>+ Executes all of the specified tasks concurrently.
help Displays this help message or prints detailed help on requested commands (run 'help <command>').
completions Displays a list of completions for the given argument string (run 'completions <string>').
; <command> (; <command>)* Runs the provided semicolon-separated commands.
early(<command>) Schedules a command to run before other commands on startup.
exit Terminates the build.
~ <command> Executes the specified command whenever source files change.

More command help available using 'help <command>' for:
!, +, ++, +-, <, ^, ^^, alias, append, apply, client, eval, iflast, java+, java++, onFailure, reboot, shell, startServer

  • console
[IJ]sbt:hello> console
[info] Starting scala interpreter...
Welcome to Scala 2.11.12 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_261).
Type in expressions for evaluation. Or try :help.

scala> object HelloWorld {
| def main(args: Array[String]): Unit = {
| println("Hello, world!")
| }
| }
defined object HelloWorld

scala> HelloWorld.main(Array())
Hello, world!

scala> :q

[success] Total time: 586 s, completed 13-Jun-2021 8:47:32 PM
[IJ]sbt:hello>


  • run
sbt:hello> run
[info] Updating ...
[info] downloading https://repo1.maven.org/maven2/org/scalactic/scalactic_2.12/3.0.5/scalactic_2.12-3.0.5.jar ...
[info] downloading https://repo1.maven.org/maven2/org/scalatest/scalatest_2.12/3.0.5/scalatest_2.12-3.0.5.jar ...
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/scala-library/2.12.8/scala-library-2.12.8.jar ...
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/scala-reflect/2.12.8/scala-reflect-2.12.8.jar ...
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.12.8/scala-compiler-2.12.8.jar ...
[info] [SUCCESSFUL ] org.scalactic#scalactic_2.12;3.0.5!scalactic_2.12.jar(bundle) (2579ms)
[info] [SUCCESSFUL ] org.scala-lang#scala-reflect;2.12.8!scala-reflect.jar (6358ms)
[info] [SUCCESSFUL ] org.scala-lang#scala-library;2.12.8!scala-library.jar (7774ms)
[info] [SUCCESSFUL ] org.scalatest#scalatest_2.12;3.0.5!scalatest_2.12.jar(bundle) (8723ms)
[info] [SUCCESSFUL ] org.scala-lang#scala-compiler;2.12.8!scala-compiler.jar (9549ms)
[info] Done updating.
[info] Compiling 1 Scala source to C:\Users\jaime\hello\target\scala-2.12\classes ...
[info] Non-compiled module 'compiler-bridge_2.12' for Scala 2.12.8. Compiling...
[info] Compilation completed in 7.218s.
[info] Done compiling.
[info] Packaging C:\Users\jaime\hello\target\scala-2.12\hello_2.12-0.1.0-SNAPSHOT.jar ...
[info] Done packaging.
[info] Running example.Hello
hello
[success] Total time: 20 s, completed Jun 12, 2021, 7:57:50 PM


  • clean

This is what I had before running clean:

C:\Users\jaime>cd hello

C:\Users\jaime\hello>dir
Volume in drive C is OS
Volume Serial Number is 5AA3-AF22

Directory of C:\Users\jaime\hello

06/12/2021 07:57 PM <DIR> .
06/12/2021 07:57 PM <DIR> ..
06/12/2021 07:55 PM 1,462 build.sbt
06/12/2021 07:57 PM <DIR> project
06/12/2021 07:55 PM <DIR> src
06/12/2021 07:57 PM <DIR> target
1 File(s) 1,462 bytes
5 Dir(s) 258,907,353,088 bytes free

C:\Users\jaime\hello>cd target

C:\Users\jaime\hello\target>dir
Volume in drive C is OS
Volume Serial Number is 5AA3-AF22

Directory of C:\Users\jaime\hello\target

06/12/2021 07:57 PM <DIR> .
06/12/2021 07:57 PM <DIR> ..
06/13/2021 08:09 PM 143 .history
06/12/2021 07:57 PM <DIR> scala-2.12
06/13/2021 02:47 AM <DIR> streams
1 File(s) 143 bytes
4 Dir(s) 258,907,369,472 bytes free

C:\Users\jaime\hello\target>cd scala-2.12

C:\Users\jaime\hello\target\scala-2.12>dir
Volume in drive C is OS
Volume Serial Number is 5AA3-AF22

Directory of C:\Users\jaime\hello\target\scala-2.12

06/12/2021 07:57 PM <DIR> .
06/12/2021 07:57 PM <DIR> ..
06/12/2021 07:57 PM <DIR> classes
06/12/2021 07:57 PM 3,871 hello_2.12-0.1.0-SNAPSHOT.jar
06/12/2021 07:57 PM <DIR> resolution-cache
1 File(s) 3,871 bytes
4 Dir(s) 258,907,316,224 bytes free

C:\Users\jaime\hello\target\scala-2.12>cd classes\example

C:\Users\jaime\hello\target\scala-2.12\classes\example>dir
Volume in drive C is OS
Volume Serial Number is 5AA3-AF22

Directory of C:\Users\jaime\hello\target\scala-2.12\classes\example

06/12/2021 07:57 PM <DIR> .
06/12/2021 07:57 PM <DIR> ..
06/12/2021 07:57 PM 901 Greeting.class
06/12/2021 07:57 PM 3,071 Hello$.class
06/12/2021 07:57 PM 738 Hello$delayedInit$body.class
06/12/2021 07:57 PM 875 Hello.class
4 File(s) 5,585 bytes
2 Dir(s) 258,902,847,488 bytes free


As expected, files produced by the build in the target directory were deleted after I ran clean:

sbt:hello> clean
[success] Total time: 0 s, completed Jun 13, 2021, 8:41:47 PM

C:\Users\jaime\hello\target\scala-2.12\classes\example>dir
Volume in drive C is OS
Volume Serial Number is 5AA3-AF22

Directory of C:\Users\jaime\hello\target\scala-2.12\classes\example

06/13/2021 08:41 PM <DIR> .
06/13/2021 08:41 PM <DIR> ..
0 File(s) 0 bytes
2 Dir(s) 258,907,795,456 bytes free


  • sbtVersion
[info] 1.2.7

Created: 2021-06-13 09:36:00 Last updated: 2021-06-14 02:57:04

"IDE
  1. We recommend to use one of the following IDEs
    • IntelliJ IDEA
    • Eclipse" (Section Introduction > Initial Setup > Exercise: Initial Setup)

I use IntelliJ IDEA.

Created: 2021-06-23 00:41:55 Last updated: 2021-06-23 00:41:55

"Exercise: Define a Class (7:00)

Exercise Format


The exercises will contain three sections.

  1. A brief video introduction to the exercise.
  2. Exercise instructions in text form.
  3. A video review of the exercise solution.
Each exercise is discussed in the presentation slide video preceding the exercise. Please attempt each exercise initially without the solution review: you can review/replay the preceding presentation slide video looking for clues on how to complete the exercise. Use the solution review video if required for help or as a way to check your completed work.

Note: The exercise videos show that there is a man e page available inside the sbt terminal session. The exercise zip for this course does not include exercise instruction man e pages. You need to use the exercise instructions inside this Lightbend Academy course.

  1. Your coding work area in the case study is the LSL-P-lightbend-scala-language-professional-< version >/exercises/exercises project directory
  2. You will run sbt from the LSL-P-lightbend-scala-language-professional-< version >/exercises directory
  3. Use the nextExercise command to move from man [e] > Lightbend Scala Language - Professional > initial-state > to man [e] > Lightbend Scala Language - Professional > define-a-class >
  4. Create the Train class
  5. Use the src/main/scala source folder of the coding work area project directory exercises
  6. Use Train.scala as the file name
  7. When done, create an instance in the REPL
  8. Use the nextExercise command to move to the next exercise" (Section OO Basics > Classes > Exercise: Define a Class (7:00))

See the steps for my solution below before looking at the course solution.

Create a new Scala Class.

Create a new Scala Class

Use Train as the class name.

Use Train as the class name

Create the Train class.

Create the Train class

Create an instance of the Train class in the REPL.

Instance of the Train class in the REPL

Modify the class, compile it, and execute it again to see the changes from the REPL.

Modify class and execute it again

Move to the next exercise by using the nextExercise command.

Use nextExercise command to move to the next exercise

Created: 2021-08-01 03:16:21 Last updated: 2021-08-01 03:16:21

Top