Tip:
Highlight text to annotate it
X
Hi. In this video, we are going to show you
how to install all the required tools for our class on your machine.
This video is for Windows users. If you are on a different operating
system, check the getting started section of the video lectures on the class web
site. Everything that we show in this video is
also described on the Wiki page tools setup on the class web site.
So we go to the tools set up page and we see there are three things that we need to
install. The first one's JDK, the Java run-time
environment which is used to execute Scalar programs.
The second environment is SBT, a build tool for Scalar projects, which in this
class you will also use to submit your assignment solutions to Coursera.
The third one is the Scalar ID for Eclipse and the Scalar worksheet, which is the ID
that we are going to use during this class.
So let's get started with the JDK. So we check the JDK section and there are
three subsections for each operating systems, so we go to windows.
First of all we need to download the JDK installer from this URL from the Oracle
website. The first thing you need to do is accept
the license agreement. And then, you can download the JDK
distribution for your architecture. In my case, I am on X64, so I will
download this file. Once the download has finished, you just
run the downloaded executable installer. You don't have to change any of the
predefined settings. The default options are fine.
The installer will also ask you to install the Java Run Time environment.
Again, you can just follow the default options.
Okay. Once you've finished, you click close, and
you close the [inaudible] websites. You don't need to register.
To finish the JDK installation, you need top add the Bing directory of the JDK that
you just installed to the path environment variable.
How to do this is described on this website here.
I will show you how to do this on Windows seven You go to the start menu control
panel and in the search box, you type environment variable and then you get the,
the option to edit the system environment variables.
So you click there. And you click on the button "invariant
variables." In the list of system variables, you search for the variable
named path, and you double click on it. To this list of directories, we will now
add the bin directory of the JDK. So you go to the start menu, computer,
local disk, program files, Java. You go to the JDK bin directory.
And by taking in the location bar, we can copy this path by right clicking.
You go back to the system variable window. And we need to add the semicolon and pace
with control B the bin directory of the JBK You finish up with Okay, and closing
all the dialogues. You can also close the, all the Explorer
windows. Okay.
So, now to test that the JDK installation is successful, you have to open a command
prompt. Command prompt can be found in the start
menu, either by typing, by searching for command prompt.
Or, you can just go to start, all programs, and then accessories, and you
have the command prompt. So, to check the java installation, type
java-version and you should see the version number of the java you just
installed. The second step is installing SBT.
Again, we scroll down to the window section.
And as you can see, we have to download SBT from this URL, so we click here.
And we already downloaded installer. Again, you can leave all the different
options, and just hit Install. Okay, once SVT is installed we also verify
that everything is correctly set up. So we are going to start and to the
comment prompt and then to test SVT we have to type the following comment.
Svt SVT-Version and now SVT will download. A few dependencies and libraries, but this
will only happen the first time you run SPTF with that, into a start, start drop
much faster. Okay.
At the end, SPT will show you its version number, which is supposed to be 0.12.0.
Okay, we can exit the common problem. Now the last thing we need to do is to
installing the scholar id for Eclipse. This Scala ID for Eclipse can be
downloaded from the following URL. On this website, you just scroll down to
the list of downloads. And, you select the package according to
your operating system. Once the download has finished, we open
the downloads folder in explorer. You right click archive and select extract
all. I'm going to instruct the, the eclipse,
that's call a id for eclipse to my desktop.
Good. Once that Windows has finished extracting
the safe file. We will close the Explorer windows and
also the id download site. Now we have to start Eclipse.
So for that you go the, the desktop. We go to the Eclipse folder and we just
run the Eclipse executable. Now, whenever you start Eclipse you have
to tell it which workspace to use. For our class, we recommend that you
create one single workspace that you can then reuse over all of the assignments.
So I will do that now. I go to my home folder.
And I make a new folder, which I called [inaudible] workspace.
And I say like that, that's my Eclipse workspace.
Okay, so this is the Scalar ID for Eclipse.
In order to test whether everything has been set up correctly, we go back to the
wiki page. And we create a small Hello World word
project in Eclipse, according to the steps described on this page.
I will just do it in Eclipse right now. So I maximize the window.
I slect file, new, Scala project. And, I give it a name.
Hell. Hello, world.'Kay?
So in every Eclipse workspace, you can have multiple projects.
Now, in order to create, hello word, program in Scala, we right click on the
source folder. Select new Scalar object.
And, we create the Scala object, which we call, hello, for instance.
And we, usually put Scalar code into a package, so we create package, which is
named cre-, creator. Okay, now the extra code for the Hello
World is given on the tool setup page. So we got back to the tool setup page and
we scroll down, To see the source code, and we just copy it and paste it inside
Eclipse. Okay?
We save the file, and you see when you save the file, Eclipse will immediately
compile the work space, the entire project.
Okay, once the file has been compiled, we can run the Hello World program, by right
clicking on the hello.scalar source file. Choosing run as inside the, I think Scalar
application. You will see now that I put the Hello
World program in the Eclipse console. Okay, this installation of Eclipse also
comes with a brand new feature which is called the Scalar worksheet.
Creating a Scalar worksheet is easy, and is again described on the tools setup wiki
page. You can read through the instructions
here. I will just retry it now in Eclipse.
So right click on the greeter package. We select new.
And we choose scalar worksheet. We give the worksheet a name.
Okay? This will give us a new Scala object, in
which we can write arbitrary Scala expressions, and those will be evaluated
on the fly. To get an example, I we have some code on
the Tool Setup page that we can just copy and paste into the worksheet that we just
created. Okay.
And once you save the file. Eclipse will evaluate all the code that is
in this worksheet object. So you can see we define a value X.
To be one we define an increase function which returns its argument increased by
one. And then to test it we just invoke the
increase function and pass x into it and you see that the result is two.
You can change a definition for instance. Now we say x to be five and once you save
the file the change will be immediately reflected in the rest of the worksheet.