Installing Java, Scala and Vim support on Linux

Here’s a quick guide on how to install Scala on linux (in my case Ubuntu 9.04). A prerequisite obviously is to have the sun jdk installed and properly integrated into your linux environment. For completeness I detail how I normally tend to set up the jdk on my linux environment before moving onto the installation of Scala. Note that here /opt/ is used as the destination directory for installation as that is what I prefer but this can be any directory that you have write permissions on. You’ll also note that I don’t use any automated linux installation tool like apt-get and that is deliberate as the following methods of installation allow you not only complete control of installation of the packages but greater flexibility when upgrading. Finally we’ll look at adding Scala support to my favourite command line editor – Vim.

Install Sun JDK

Download the latest Sun JDK (JDK 6 Update 14 at time of writing).

Make executable and extract.

$ chmod u+x jdk-6u14-linux-i586.bin
$ ./jdk-6u14-linux-i586.bin


$ mv jdk1.6.0_14/ /opt/


$ cd /opt/
$ ln -s jdk1.6.0_14/ java

In /etc/profile set JAVA_HOME variable and add JDK bin directory to system path.

export JAVA_HOME="/opt/java"
export PATH="${JAVA_HOME}/bin:${PATH}"

Import your newly modified profile

$ source /etc/profile

Test Java.

$ java -version
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) Server VM (build 14.0-b16, mixed mode)
$ javac -version
javac 1.6.0_14

Install Scala

Download the latest Scala (2.7.5 at time of writing).


$ tar -xvzf


$ mv /opt/


$ cd /opt/
$ ln -s scala

In /etc/profile set SCALA_HOME environment variable and add the Scala bin directory to your system path.

export SCALA_HOME="/opt/scala"
export PATH="${SCALA_HOME}/bin:${JAVA_HOME}/bin:${PATH}"

Import your newly modified profile

$ source /etc/profile

Test Scala.

$ scala
Welcome to Scala version (Java HotSpot(TM) Server VM, Java 1.6.0_14).
Type in expressions to have them evaluated.
Type :help for more information.

scala> 1+1
res0: Int = 2

scala> println("Hello World!")
Hello World!

Add Scala support into Vim

If you’re like me and you can’t live without Vim or you just need Vim to get started with Scala prior to moving onto your favourite IDE then here’s how you can add Scala support into Vim.

Create required vim directories.

$ mkdir -pv ~/.vim/ftdetect
$ mkdir -pv ~/.vim/indent
$ mkdir -pv ~/.vim/syntax

Download Scala support into vim directories.

$ wget --no-check-certificate -O ~/.vim/ftdetect/scala.vim
$ wget --no-check-certificate -O ~/.vim/indent/scala.vim
$ wget --no-check-certificate -O ~/.vim/syntax/scala.vim

Create a basic ~/.vimrc configuration if you haven’t got one.

set nocompatible
set nu  
syntax on
filetype indent on
set autoindent
set ic
set hls 
set lbr 
colorscheme delek

Try editing a Scala file. It should appear in colour.

1 for {i <- 1 to 10
2 j <- 1 to 10}
3 println(i*j)

Rejoice. Get coffee. Develop. Lose sleep. The usual lifecycle.

Acknowledgements (Scala Vim support, Vim colorised output).

9 thoughts on “Installing Java, Scala and Vim support on Linux

  1. David Rutkowski

    Even works for the quasi-vimgorant. After installing two highliters, yours worked right off. Thanks! I’m anxious to get into Java (for mobile development) but avoid the utter boredom of learning a language seemingly designed to protect the programmer from occasional bouts with pure creativity. Scala might be a side door to the cathedral, just off the bazaar. Near the cindered arches.

  2. Pingback: Installing Java, Scala and Vim support on Linux | 做人要豁達大道

Leave a Reply