Scala Development Environment Construction

Source: Internet
Author: User
0. Scala introduction (pronounced /? SK certificate? L ?, ? Ske? L? /) Is a multi-paradigm programming language designed to integrate various features of object-oriented programming and functional programming.

Scala runs on the Java platform (Java Virtual Machine) and is compatible with existing Java programs. Scala compilation model (independent compilation and dynamic class loading) is the same as Java and C #. Therefore, scala code can call Java class libraries (. NET class libraries can be called for. Net implementations ).

Scala packages include compilers and class libraries, which are released with a BSD license.

1. download the required software jdkscala is JVM-based, so you must download the JDK, link for http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Scala compiler http://www.scala-lang.org/download/ can choose several versions, I see the Open Class recommended is 2.10.2, so the next is 2.10.2, not the latest.

After the download, you need to set the environment variable. Scala seems to have been set automatically. JDK and classpath must be set manually.
2. Execute the program under interactive command line

Execute the scala file in the command line // helloworld. Scala
object HelloWorld {  def main(args: Array[String]) {    println("Hello, World!")  }}

Run the following command:
F:\scala_workspace\helloworld>scala helloworld.scalaHello, World!

Or compile the file into. Class bytecode before executing
F:\scala_workspace\helloworld>scalac helloworld.scala
F:\scala_workspace\helloworld>scala -classpath . HelloWorldHello, World!
Or Scala-CP. helloworld
Note that "-classpath." must be included in the second sentence; otherwise, "No such file or class on classpath: helloworld" will pop up ".

Scala compiles the. Scala file into a. Class file. As we all know, the. Class file Java can also execute
F:\scala_workspace\helloworld>java -classpath ".;D:\Program Files\scala\lib\scala-library.jar" HelloWorldHello, World!

Note that you must specify-classpath ".; D: \ Program Files \ Scala \ Lib \ scala-library.jar" either side of the semicolon .And D: \ Program Files \ Scala \ Lib \ scala-library.jarIndispensable!
It can be seen that, whether using Scala or Java to execute the. Class file, they must manually carry-classpath, which is very troublesome. Is there any way not to bring this damn-classpath option? Yes, it is specified in the classpath environment variable: in Windows 7, right-click computer> Properties> advanced system Settings> environment variables> edit classpath is the last line.

The execution result is:

3. Commonly Used ides used by IDE to execute Scala include Scala-ide and intellij-idea. The latter has never been used. Here we will only introduce Scala-ide. Http://typesafe.com/stack/scala_ide_download (make sure to download the IDE for Scala version 2.10.2 !)
After the download, decompress the package and open it. Then you can create a simple helloworld project: 1. [file] -- [new] -- [other] -- [Scala wizards] -- [Scala project] 2. write the project name and click "finish"
3. [file] -- [new] -- [Scala object]

Click the green triangle and the result is executed perfectly! The Scala Compilation speed is the slowest in compiled programming languages !! Well, this article mainly introduces the establishment of scala development environment and the summary of several execution methods.
4. References https://class.coursera.org/progfun-004/wiki/view? Page = toolssetup
Http://book.51cto.com/art/201008/218451.htm
Http://zh.wikipedia.org/wiki/Scala

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.