11

In Ubuntu terminal when I write the command below:

scala -version

It gives the following Output:

Scala code runner version 2.9.2 -- Copyright 2002-2011, LAMP/EPFL

I want to update this to 2.11.8. I downloaded the tar file

scala-2.11.8.tgz

and untared it to get

scala-2.11.8

folder in "/home/hdadmin/" location.

But still when I check the scala-version again it shows the same 2.9.2 version. It is picking scala version from

/usr/bin/scala

instead of

/home/hdadmin/scala-2.11.8

Is there a way to change this path?

I tried uninstalling & reinstalling scala using commands below:

sudo apt-get remove scala
sudo apt-get remove scala-library scala
sudo apt-get install scala

But the same version(2.9.2) gets installed because I think it comes by default with Java(1.8) that I have. There are some very unclear option online to update using sbt or deb or in the link http://osgux.tumblr.com/post/44635945407/install-scala-2-10-0-in-ubuntu.

I need to know if there is a direct way to update scala version.

3 Answers 3

8

If you want to remove the old scala from your computer, you have to delete the previously extracted scala folder. To know the path to old scala

which scala

It will show you the path upto ..../bin/scala
You can delete the parent folder (before bin folder) to remove the old scala.
For the new scala to be recognized by the system, the executable binary file path need to be put in PATH of the system if you haven't done so. Or you need to edit the path to point to the new scala. As @Mureinik suggested, you need to set two variables in ~/.bashrc file

export SCALA_HOME=/home/hdadmin/scala-2.11.8

And

export PATH=$PATH:$SCALA_HOME/bin

Then either you restart your terminal or do one of the following commands

source ~/.bashrc

Or

. ~/.bashrc

Now

scala -version

should show you the right version.

1
  • Thankyou Ramesh for the reply..it was addition of scala path in .bashrc file that solved the issue Commented May 20, 2017 at 16:02
3

You need to add /home/hdadmin/scala-2.11.8 at the beginning of your $PATH, so the executable is taken from there first:

export PATH=/home/hdadmin/scala-2.11.8:${PATH}

You can place this call in your .bashrc (or the equivalent in your own environment if you aren't using ).

0
1

You can try SKDMAN, perhaps the easiest way to manage versions of not only scala, but also java, sbt and spark (among other things).

Not the answer you're looking for? Browse other questions tagged or ask your own question.