How to install Scala?

11,187

From the README file in

 cat /opt/scala/doc/README

I took this:

Scala Software Distributions
----------------------------

- scala-<major>.<minor>.<patch>.tar.bz2     Unix distribution
- scala-<major>.<minor>.<patch>.tar.gz      Unix distribution
- scala-<major>.<minor>.<patch>.zip         Windows distribution

The standard distributions require Java 1.5 or above. If you don't
know which version of Java you have, run the command "java -version".


Scala Tools
-----------

- fsc         Scala offline compiler
- scalac      Scala compiler
- scaladoc    Scala API documentation generator
- scala       Scala interactive interpreter
- scalap      Scala classfile decoder 

Run the command "scalac -help" to display the list of available
compiler options.


Unix Installation
-----------------

Untar the archive. All Scala tools are located in the "bin" directory.
Adding that directory to the PATH variable will make the Scala commands
directly accessible.

You may test the distribution by running the following commands:

$ ./bin/sbaz install scala-devel-docs
$ ./bin/scalac doc/scala-devel-docs/examples/sort.scala
$ ./bin/scala examples.sort
[6,2,8,5,1]
[1,2,5,6,8]
$ ./bin/scala
scala> examples.sort.main(null)
[6,2,8,5,1]
[1,2,5,6,8]
scala>:quit
$

(omitted: Windows-notes)

Does this take you a step further?

Share:
11,187

Related videos on Youtube

greenoldman
Author by

greenoldman

I am interested in such topics: usability and accessibility of user interfaces, design of programming languages, natural language processing, machine translation, data mining. Currently I am developing compiler and programming language Skila -- read more at aboutskila.wordpress.com.

Updated on September 18, 2022

Comments

  • greenoldman
    greenoldman almost 2 years

    Please note: I have to use the source package, not the prebuilt package from the repo (it is broken, at least IDEA complains).

    From the page: http://www.scala-lang.org/downloads I downloaded scala.final.tgz package. I installed it by unpacking to /usr/local/share.

    However, when I run IntelliJ IDEA and point to this directory it complains about missing /doc/scala-devel-doc... (maybe there is something more missing, but IDEA cuts off the rest).

    I also downloaded scala.final-devel-docs.tgz but it complains about the same missing file.

    In none of those packages are any instructions on how to install scala. The scala web page also lacks any information how to install it (except for a remark that the tgz file can be unpacked with tar).

    openSUSE 11.4, IntelliJ IDEA 10.5.2.

    Solution, use Eclipse Luke...

    As the life goes on, it appears I tend to avoid broken ideas/products/etc altogether, instead of fixing them.

    Anyway, maybe someone will find it useful.

    • IntelliJ didn't complain about missing .jar package but missing subdirectory
    • you can download docs extra package manually and then unpack it to the directory YOUR_SCALA_MAIN_DIR/doc/scala-devel-docs (watch for the naming, tgz file has some naming added -- rename it after unpacking)
    • the installation "instruction" is completely wrong -- the first command does not test anything, it installs extra package
    • once installed, you cannot test installation, because you won't have enough rights for the system files -- and testing something at the system level as root... not clever
    • and besides, it wouldn't even work because the code expects files in different location that you are assumed to be (easy to fix, though)
    • and on top of that IntelliJ still won't run your code!

    And now for comparison -- in Eclipse (despite all comments about very unstable Scala plugin) not only I didn't have to configure anything, not only my own test code was compiled in an instant (IntelliJ takes some time), but also it was executed, and ran without any errors.

    Same Scala was used. How about difference?

    @user unknown, thank you very much for your help! Thanks to you I have more complete Scala installation.

    ...or IntellIJ

    After some struggle I managed to set up IntelliJ as well. Maybe there is simpler way, but this worked for me:

    • install Scala
    • install IntelliJ
    • install Scala plugin
    • create Scala dummy project
    • quit IntellIJ
    • go to your personal settings IntelliJ directory
    • edit config/options/applicationLibraries.xml
    • there should be 3 sections -- one with empty label, one for compiler, one for library, delete entirely the first section (with empty label)
    • run IntelliJ again, that's it

    I installed IntellIJ along with Eclipse, because Eclipse has very strange way of treating projects.

  • greenoldman
    greenoldman almost 13 years
    Sorry, no. I know how untar the archive, the required files are not there. Well, I could suspect IntelliJ has too high demands, by I think they didn't take those filenames just from thin air.
  • user unknown
    user unknown almost 13 years
    Did you do the tests, mentioned in the last paragraph?
  • greenoldman
    greenoldman almost 13 years
    Thank you, yes, but I simply give up -- if the authors of Scala package cannot give clear explanation of installation, and on the other hand Eclipse works, then I stick to Eclipse and maybe some day it will be fixed.