Installing Scala on the Raspberry PI
Start out with a vanilla version of Raspbian, this already will have Oracle Java installed
Now being an old fashioned kind of guy I like to find my Raspberry PI where I left it, and to do this I like to have a static IP address. In Raspbian its pretty simple to set up
just edit the /etc/network/interfaces file
sudo vi /etc/network/interfaces
then replace the lines:
iface eth0 inet dhcp
with
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
gateway 192.168.1.254
obviously changing the ip addresses so they match your network preferences. Then double check for typos, and correct if necessary then reboot
the next step is to down load sbt, sbt is the Scala Build Tool, it will manage dependencies in a very maven like manner. Here I am downloading 0.13.1-RC5 but download the latest and greatest by checking the parent directory in a web browser.
cd ~
wget http://scalasbt.artifactoryonline.com/scalasbt/sbt-native-packages/org/scala-sbt/sbt/0.13.1-RC5/sbt.deb
sudo dpkg -i sbt.deb
Now its time to run up sbt; since we are on a PI lets set the memory to something a little bit more manageable:
sbt – mem 128
Now go get a cup of tea while sbt does its magic
now we should be presented with
[info] Set current project to pi (in build file:/home/pi/)
>
now type in console to start the repl
> console
[info] Starting scala interpreter…
[info]
Welcome to Scala version 2.10.3 (Java HotSpot(TM) Client VM, Java 1.7.0_40).
Type in expressions to have them evaluated.
Type :help for more information.
scala>
so now we can add 1+1 and 2, or One + One and get OneOne
scala> 1+1
res0: Int = 2
scala> “One” + “One”
res2: String = OneOne
Next time I will do something a little more fun.