34

I installed Scala on Ubuntu using the following

sudo apt-get install scala 

~$ which scala
/usr/bin/scala

~$ whereis scala
scala: /usr/bin/scala /usr/bin/X11/scala /usr/share/man/man1/scala.1.gz

~$ scala -version
Scala code runner version 2.9.1 -- Copyright 2002-2011, LAMP/EPFL

My question is what should I put in the variable SCALA_HOME? /usr/bin ?

Soumya Simanta
  • 11,523
  • 24
  • 106
  • 161
  • 2
    Try using `SCALA_HOME=/usr/share/java`. There's a possibility may need to symlink specific jars from that directory into `/usr/share/java/lib`. I think a cleaner and more reliable solution is installing scala from the tarball into a single directory. – Alex Apr 02 '13 at 20:41
  • 1. cd / 2. sudo find . -name scala-compiler*.jar 3. check if its available in which of the following location a. /usr/shar/java b. /usr/share/scala/lib/ 4. the directory where scala compiler jar is present is scala home – urmalp Oct 10 '15 at 22:56

7 Answers7

17

Today I installed scala using "apt-get install scala" and confirmed the scala jar files are located in /usr/share/java

You should be able to set your SCALA_HOME to /usr/share/java and have it all work. I assume you want to use NetBeans so you will need to set SCALA_HOME in your .profile (or .bash_profile) rather than in your .bashrc because NetBeans won't see any variables set in your .bashrc unless you start it from the command line

$ find / -maxdepth 6 -iname \*scala\*jar 2> /dev/null
/usr/share/java/scala-dbc.jar
/usr/share/java/scala-partest.jar
/usr/share/java/scala-partest-2.9.1.jar
/usr/share/java/scala-dbc-2.9.1.jar
/usr/share/java/scalacheck.jar
/usr/share/java/scalap.jar
/usr/share/java/scala-library-2.9.1.jar
/usr/share/java/scala-compiler-2.9.1.jar
/usr/share/java/scala-library.jar
/usr/share/java/scalacheck-2.9.1.jar
/usr/share/java/scala-compiler.jar
/usr/share/java/scala-swing-2.9.1.jar
/usr/share/java/scalap-2.9.1.jar
/usr/share/java/scala-swing.jar
Colonel Thirty Two
  • 23,953
  • 8
  • 45
  • 85
Tim Perry
  • 3,066
  • 1
  • 24
  • 40
12

For me its: /usr/share/java/scala I determined this by doing dpkg -L scala

This assumes you install scala using APT.

TN888
  • 7,659
  • 9
  • 48
  • 84
Jeremy
  • 2,249
  • 2
  • 17
  • 18
  • I only have `jline.jar` in that folder... On the other hand if you go one level up that is `/ust/share/java/` you get all the scala-related goodies. – rbaleksandar Nov 22 '15 at 11:41
9

As of today I couldn't find an easy (and reliable) way of setting this.

As per Alex (in the comment above) installing from tarball (downloaded from scala-lang.org) into /location/of/scala/untar

Then I set export SCALA_HOME=/location/of/scala/untar in my .bashrc Everything works for now!

nitinr708
  • 1,393
  • 2
  • 19
  • 29
Soumya Simanta
  • 11,523
  • 24
  • 106
  • 161
6

I had the same issue and I did some digging This takes into account that you are using sudo dpkg -i scala-2.11.4.deb; where the debian package has been downloaded

The SCALA_HOME should be /usr/share/scala; This is based on the following

  • /usr/bin/scala is a symbolic link to /usr/share/scala/bin/scala
  • /usr/bin/X11/scala is also a symbolic link to /usr/share/scala/bin/scala

The way I see the scala package is installed in /usr/share/scala which should be your SCALA_HOME

DataGuru
  • 757
  • 7
  • 17
  • Scala from Ubuntu's repositories is nowhere to be found in the directories you have mentioned. I wonder who thought that it's funny to waste hours in searching for the damn location where this thing is installed instead of just using it?! -_- – rbaleksandar Nov 22 '15 at 11:40
2

If you have installed Scala using

$apt-get install scala

then, after a successful install to see where it installed, run

which scala

If this command shows you the path to scala binaries. Now run

pwd

Now export SCALA_HOME path into either of these environment files

~/.bashrc

or

/etc/profile

export SCALA_HOME=<output of pwd>
nitinr708
  • 1,393
  • 2
  • 19
  • 29
  • I like your method better, but you might want to edit your answer to include cd to directory provided by `which scala` or better yet, just copy it and paste into the profile. – Shanemeister Apr 28 '18 at 18:22
2

I installed the untarred scala into /usr/local/share as it is on the scala download site.

In my .bashrc, I placed the following line:

export PATH="/usr/local/share/scala-2.11.8/bin:$PATH"

works great from terminal regardless of what directory I'm in.

Maxim Kolesnikov
  • 5,075
  • 6
  • 38
  • 68
wayneeusa
  • 194
  • 1
  • 10
-2

The SCALA_HOME should be the directory where you install scala from. For example, the name of this directory may be scala-2.9.2.

Seraph
  • 1
  • 2
    I think the question was: for ubuntu, where might scala be in order that I can properly set SCALA_HOME. – Richard Sitze Jul 27 '13 at 19:39
  • OK. I think usually the 'sudo apt-get' command will install software under /opt or /usr/local. Maybe he can try to find scala-2.9.2 folder under those directories – Seraph Sep 10 '13 at 22:03
  • 2
    @Seraph any package that touches either of those directories is by definition broken – stew Jun 03 '14 at 19:37