1.Scala and Scala Eclipse plugin installation and use

Source: Internet
Author: User

工欲善其事, its prerequisite. This is also true for Scala, where you have to complete the installation of Scala and choose the right IDE before you start learning Scala

This paper is mainly divided into two parts:

Installation of 1.scala2.11.6 and use of REPL

Installation and use of the 2.Scala eclipse plugin

1.scala2.11.6 installation and use of REPL

This section mainly describes the installation of Scala2.11.6 and the use of REPL, relatively simple. If your Scala is ready to install, skip this section directly.

1.1.scala2.11.6 Installation

Download the appropriate installation package on the Scala website (Scala website address: http://www.scala-lang.org/download/)

My local operating system is WINDOW7, so select Scala-2.11.6.msi Install package for download

If you download directly from the official website, the download is too slow. Can be downloaded from my shared Baidu cloud disk. (Baidu Cloud disk download link)

The download is complete and the installation begins below. In fact, for the MSI of this Windows Installer installation package, you should be able to more smoothly install the complete.

To install Scala-2.11.6.msi Open the Setup wizard:

Next can

Check acceptance agreement, Next

Take a look at the picture above:

Update system path means that the installer helps you append the Scala bin directory to the PATH environment

Brower ... button can customize the installation location, we intend to install to the D drive, modified as follows:

Next can

Click Install to start the installation

Wait a moment and the installation is complete. Click Finish.

1.2.REPL use

REPL (Read-eval-print-loop) namely: Read-execute-print-loop.

To get into Scala's Repl, enter the Scala command directly in the CMD window

In the REPL Interactive console, we can enter Scala's expression directly. Scala will show us the results of the execution. For example:

We first entered Scala's expression in REPL:

When Scala executes, the execution results are echoed. The format shown is: variable name to save the result: type: =: result

For example, the execution result of the 2, the data type int, is saved to Res0.

In subsequent expressions we can use the previous variables, as we can enter: res0*2

You can enter in REPL: Help (with a colon on the front) to see the commands built into REPL

Exit REPL Input: Quit or: Q!

Installation and use of the 2.Scala eclipse plugin

A large number of Scala programmers are coming from Java, and most Java programmers are mostly familiar with the Eclipse IDE. It is gratifying that Scala also has eclipse

Plug - ins. After installing the Scala Eclipse plugin, we can write Scala programs in Eclipse. This article uses an offline approach to install the Scala eclipse plugin

First download the offline installation package to the Scala Eclipse plugin. can also go to my Baidu cloud disk download (download link)

Download complete decompression, decompression results are as follows:

Delete Artifacts.jar and Content.jar two files (the role of these two files is to do local update site when used)

Then create a new Scala directory under the Dropins directory in the installation directory of Eclipse

Finally, copy the features and plugins directories to the <eclipse_home>/dropins/scala directory.

Finally, under CMD, restart Eclipse with the-clean parameter.

Scala's Eclipse plugin plugin is already built into Scala. But we want to use our own Scala compilers and actuators, which can be set up as follows:

To the Eclipse Windows->preferences, find the following location:

You can see that Scala, which is used by default, is build-in (built-in). We click the Add button to add the Scala you just installed. Once you've added it, you'll be able to see the Scala you added.

Here we create a new Scala project

File->new->other

Take a name for the project

Clicking Finish will prompt you to open the Scala perspective and open it.

Modify the Scala used by the project. Right-click->properties on the project

Click OK to finish.

Let's start with a new class test. Instead of focusing on grammar, the goal of our testing is to ensure that Scala's eclipse plugin works properly

In the New Scala Object dialog box that pops up, fill in the package name and the object (singleton) name

The following code is generated:

We add some code:

Run:

To view the results in the console view:

At this point, the Scala installation, the use of REPL and the installation and use of the Scala Eclipse plugin are complete.

1.Scala and Scala Eclipse plugin installation and use

Related Article

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.