Where is SCALA_HOME on Ubuntu?

2019-02-01 18:40发布

问题:

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 ?

回答1:

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


回答2:

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

This assumes you install scala using APT.



回答3:

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!



回答4:

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



回答5:

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.



回答6:

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>


回答7:

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.