Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The process of installing Scala on Windows and running Hello World on idea

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains the process of installing Scala on Windows and running Hello World on idea. The explanation in this article is simple and clear and easy to learn and understand. Please follow the editor's train of thought to study and learn the process of installing Scala on Windows and running Hello World on idea.

I. Preface

Recently, I have a whim to learn Scala. You see, both Spark and Kafka are implemented in Scala, so if you want to work in big data development later, I think it is necessary to learn Scala.

Did not expect to install Scala on Windows and run the Scala version of Hello World on idea will be a problem, so this article is a record of their own crawl, but also convenient for future generations to use.

2. Install Scala on Windows

The prerequisite for installing the Scala environment is to install the Java environment, and my java version is 1.8.0. 131.

Open the download page of Scala official website: https://www.scala-lang.org/download/. We choose the latest version of Scala to download, and we download the msi file in Windows environment, as shown below:

Double-click the scala2.13.0.msi file to customize the scala installation directory, and the environment variables will be automatically set (inside Path).

When you are done, we open the cmd pop-up window and view the scala version:

Use idea to run Hello World in Scala language

If you use idea to develop a Scala project, you need to do three things:

Configure jdk, which is generally configured.

It is strongly recommended to install a Scala plug-in, otherwise it will be difficult for you to write Scala code.

Configure Scala SDK. (I was trapped here.)

The idea version I used before is 2017.2.1, which is naturally compatible with the Scala plug-in, but this is not compatible with Scala 2.13.0, so I installed the latest flagship version of idea 2019.1.3, which is appropriate.

1. Install idea 2019.1.3 Ultimate Edition

(omitted).

2. Install the scala2019.1.9 plug-in

3. Set the encoding format to UTF-8

4. Create a Scala project

Just click Finish.

5. Create a Scala file

Right-click new Scala Class, and select Object for Kind, as shown below:

Object HelloWorld {

Def main (args: Array [String]): Unit = {

Println ("Hello World!")

}

}

Run the project. If successful, congratulations, Scala's Windows development environment is finally set up. It's okay if I fail, keep looking down, and then there's my summary of climbing through the hole.

IV. Error reporting and solutions

Scala error:

Error:scalac:Error: org.jetbrains.jps.incremental.scala.remote.ServerException either cannot find or cannot load the main class HelloWorld. As shown in the following figure:

According to my experience, if the above two errors occur except that the Scala version does not match the idea version, it is that Scala SDK is not configured.

Delete the original Scala SDK and add the Scala SDK again, as shown in the following figure:

Add all jar packages under the installed Scala lib, as shown in the following figure:

Open Modules-- > Dependencies again, and check scala-sdk-2.13.0.

Try to run the Scala program again at this time, and it should be fine.

Although it is very simple to say, but after the error report of the demo project, I am really puzzled. It is said on the Internet that the mismatch between the Scala and idea versions is caused, but it is useless for me to lower the version, but fortunately, I finally found a solution. So for the record here, I also hope that the newcomers will save some time and visit the pit less.

Thank you for reading, the above is "the process of installing Scala on Windows and running Hello World on idea". After the study of this article, I believe you have a deeper understanding of the process of installing Scala on Windows and running Hello World on idea, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report