Desktop tool for Mac OS X 14. Mac OS X Desktop Widget 15. Opera Extension 16. Pastebin Ruby Gem 18. PastebinPython (Python Wrapper) 19. Brush (PHP Wrapper) 20. Pastebin.cs (C# Wrapper) 21. JPastebin (Java Wrapper) 22. Pastebin4Scala (Scala Wrapper) 23. PasteBin IntelliJ IDEA Plugin 24. Read reviews, compare customer ratings, see screenshots, and learn more about Spark – Email App by Readdle. Download Spark – Email App by Readdle for macOS 10.13 or later and enjoy it on your Mac. How to Install Scala and Apache Spark on MacOS. Here is a Step by Step guide to installing Scala and Apache Spark on MacOS. Step 1: Get Homebrew. Homebrew makes your life a lot easier when it comes to installing applications and languages on a Mac OS. You can get Homebrew by following the instructions on it’s website.
We will be installing following tools for writing and running Scala code:
These tools will be all you need from your first line of Scala code tobuilding and deploying production systems in Scala.
2.1 Windows Setup (Optional)
If you are on Windows, the easiest way to get started using Scala is to use theWindows Subsystem for Linux 2 (WSL2) to provide a unix-like environment to runyour code in. This can be done by following the documentation on the Microsoftwebsite:
WSL2 allows you to choose which Linux environment to host on your Windowscomputer. For this book, we will be using Ubuntu 18.04 LTS.
Completing the setup, you should have a Ubuntu terminal open with a standardlinux filesystem and your Windows filesystem available under the
folder:
The files in
are shared between your Windows environment and yourLinux environment:
Many of the chapters in this book assume you are running your code in WSL2'sUbuntu/Linux environment, while graphical editors like IntelliJ or VSCode willneed to be running on your Windows environment, and WSL2 allows you to swapbetween Linux and Windows seamlessly. While the Scala language can also bedeveloped directly on Windows, using WSL2 will allow you to avoid compatibilityissues and other distractions as you work through this book.
2.2 Installing Java
Scala is a language that runs on the Java Virtual Machine (JVM), and needs Javapre-installed in order to run. To check if you have Java installed, open up yourcommand line (The
Terminal app on Mac OS-X, WSL2/Ubuntu on Windows) and typein the java command. If you see the following output (or somethingsimilar) it means you already have Java installed:
If you already have Java, you can skip forward toInstalling Ammonite (2.3). On the other hand, if you seesomething like the following, it means you do not have Java installed yet:
You can download and install a version of the JVM (we will be using version 11in our examples) via one of the following websites:
The installation instructions vary per operating system, but there areinstructions provided for Windows, Mac OS-X, and different flavors of Linux(
and bundles). Once you have downloaded and installed Java, goback to your command line and make sure that running the java commandcorrectly produces the above output.
If you are installing Java through the terminal, e.g. on a WSL Ubuntudistribution or on a headless server, you can do so through your standardpackage manager. e.g. on Ubuntu 18.04 that would mean the following commands:
Java versions have a high degree of compatibility, so as long as you have someversion of Java installed that should be enough to make the examples in thisbook work regardless of which specific version it is.
2.3 Installing Ammonite
Best mac os youtube app. On Mac OS-X, Linux, and Windows WSL2, we can install Ammonite via the followingcommand line commands:
This should open up the following Ammonite Scala REPL: Mac os x 10.6.0 snow leopard 32 bit free download.
Scala Mac Os App Download
Once you see this output, it means you are ready to go. You can exit Ammoniteusing
Ctrl -D.
On Max OS-X, Ammonite is also available through the Homebrew package manager via
brew install ammonite -repl
2.3.1 The Scala REPL
The Ammonite REPL is an interactive Scala command-line in which you can entercode expressions and have their result printed:
Invalid code prints an error:
You can use tab-completion after a
. to display the available methods on aparticular object, a partial method name to filter that listing, or a completemethod name to display the method signatures:
If a REPL command is taking too long to run, you can kill it via
Ctrl -C:
2.3.2 Scala Scripts
In addition to providing a REPL, Ammonite can run Scala Script files. A ScalaScript is any file containing Scala code, ending in
. Scala Scripts are alightweight way of running Scala code that is more convenient, though lessconfigurable, than using a fully-featured build tool like Mill.
For example, we can create thefollowing file
myScript .sc, using any text editor of your choice(Vim, Sublime Text,VSCode, etc.):
Note that in scripts, you need to
println each expression since scripts do notecho out their values. After that, you can then run the script via amm myScript .sc:
The first time you run the script file, it will take a moment to compile thescript to an executable. Subsequent runs will be faster since the script isalready compiled.
2.3.2.1 Watching Scripts
If you are working on a single script, you can use the
amm or amm command to watch a script and re-run it when things change:
Now whenever you make changes to the script file, it will automatically getre-compiled and re-run. This is much faster than running it over and overmanually, and is convenient when you are actively working on a single script totry and get it right.
You can edit your Scala scripts with whatever editor you feel comfortable with:IntelliJ (2.5.1),VSCode (2.5.3), or any other text editor.
2.3.3 Using Scripts from the REPL
You can open up a REPL with access to the functions in a Scala Script by running
amm with the flag. For example, given the following script:
You can then open a REPL with access to it as follows:
This is convenient when your code snippet is large enough that you want to saveit to a file and edit it in a proper editor, but you still want to use the ScalaREPL to interactively test its behavior.
Note that if you make changes to the script file, you need to exit the REPLusing
Ctrl -D and re-open it to make use of the modified script. Mac mini remote app. You can alsocombine with / , in which case when you exit with Ctrl -Dit will automatically restart the REPL if the script file has changed.
2.4 Installing Mill
Mill is a build tool for Scala projects, designed for working with larger Scalaprojects. While the Ammonite REPL and scripts are great for small pieces ofcode, they lack support for things like running unit tests, packaging your code,deployment, and other such tasks. For larger projects that require such things,you need to use a build tool like Mill.
2.4.1 Mill Projects
The easiest way to get started with Mill is to download the example project:
You can see that the example project has 4 files. A
build .sc file thatcontains the project definition, defining a module foo with a test moduletest inside:
The
test module definition above comes with a dependency on one third partylibrary: ivy 'com.lihaoyi::utest:0.7.4'. We will see other libraries as weprogress through the book and how to use them in our Mill projects.
The Scala code for the
foo module lives inside the foo /src/ folder:
While the Scala code for the
foo .test test module lives inside thefoo /test/ src/ folder:
Lastly, the example project contains a
mill Euro truck simulator 2 serial key generator. file. You can use the mill fileto compile and run the project, via :
Note that the first time you run
, it will take a few seconds todownload the correct version of Mill for you to use. While above we run both and , if you want to run your code you canalways just run . Mill will automatically re-compile your codeif necessary before running it.
To use Mill in any other project, or to start a brand-new project using Mill, itis enough to copy over the
mill script file to that project's root directory.You can also download the startup script via:
2.4.2 Running Unit TestsMac Os Download
To get started with testing in Mill, you can run
:
This shows the successful result of the one test that comes built in to theexample repository.
Mac Os Catalina2.4.3 Creating a Stand-Alone Executable
So far, we have only been running code within the Mill build tool. But what ifwe want to prepare our code to run without Mill, e.g. to deploy it to productionsystems? To do so, you can run
:
This creates an
out .jar file that can be distributed, deployed and run withoutthe Mill build tool in place. By default, Mill creates the output for thefoo .assembly task in out /foo/ assembly/ dest, but you can use toprint out the full path:
You can run the executable assembly to verify that it does what you expect:
Now your code is ready to be deployed!
![]()
In general, running Scala code in a Mill project requires a bit more setup thanrunning it interactively in the Ammonite Scala REPL or Scala Scripts, but theability to easily test and package your code is crucial for any productionsoftware.
2.5 IDE Support
The most common editors used for working with Scala programs is IntelliJ orVSCode. This section will walk you through installing both of them, but you onlyreally need to install whichever one you prefer to make your way through thisbook.
2.5.1 Installing IntelliJ for Scala
You can install IntelliJ from the following website. The free Community editionwill be enough.
Next, we need to install the IntelliJ Scala plugin, either via the loadingscreen:
or via the menu bar Izotope rx advanced review.
From there, go to the
Plugins page:
Search for
Scala and click Install . You will then need to re-start theeditor.
2.5.2 Integrating IntelliJ with Mill
Once you have IntelliJ installed on your machine, you can load your Mill projectvia the following terminal command:
Next, use IntelliJ's
File menu item and select the folder yourbuild .sc file is in. Installesd.dmg disk utility high sierra. That will open up the Mill project, with IntelliJproviding code assistance when editing all the code:
You may see a
Project JDK is not defined : Setup JDK prompt: in that case,click the Setup JDK link and select the version of Java that youinstalled earlier (2.2). Note that every time you make changes toadd dependencies or add new modules to your build .sc, you need to re-run the command, and restart IntelliJ to have itpick up the changes.
2.5.3 Visual Studio Code Support
Scala also comes with support for the Visual Studio Code text editor, via theMetals plugin:
To use VSCode within a Mill build, we need to specify the Mill version in a
file. Then you can open the folder that your Mill build is inand select Import build :
Sometimes the import may time out if your computer is slow or under load, andmay need to be retried. If you have trouble getting the import to work evenafter retrying, you can try using a more recent version of the Metals plugin.Use
F1 , search for Open Settings , and update Extensions e.g. to the latest SNAPSHOT version on the Metals/VSCodewebsite:
You can also try enabling VSCode Remote Development, by using
F1 and searchingfor Remote -WSL: Reopen in WSL. This will run the VSCode code analysis logicinside the Ubuntu virtual machine, which may be more reliable than doing sodirectly on the Windows host environment:
Once complete, you should be able to show method signature by mousing over themwith
Cmd or Ctrl .
Metals also supports other editors such as Vim, Sublime Text, Atom, and others.For more details, refer to their documentation for how to install the relevanteditor plugin:
Scala Mac Os Apps2.6 Conclusion
By now, you should have three main things set up:
We will be using Mill as the primary build tool throughout this book, as it isthe easiest to get started with. You may also encounter alternate build tools inthe wild:
Before you move on to the following chapters, take some time to experiment withthese tools: write some code in the Ammonite REPL, create some more scripts, addcode and tests to the Mill example projects and run them. These are the maintools that we will use throughout this book.
Discuss Chapter 2 online at https://www.handsonscala.com/discuss/2
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |