Astudent
Astudent

Reputation: 196

Intellij Idea - what configuration to use for Scala

I am having trouble running Scala on Intellij Idea.

I have a Scala Object (basic HelloWorld), but I am unable to run it (the run button is grayed out).

I know I need to add a configuration before running, but which one should I choose? Intellij Idea offers templates like ScalaTest and Scala REPL, but I have no knowledge on the differences of these or what options I should set on them, or if should use either of them. I couldn't find tutorials on this either.

enter image description here

Upvotes: 2

Views: 361

Answers (3)

Salim
Salim

Reputation: 2178

You can add Scala under your existing project as following.

Under project set up (command + ;) -> global libraries -> + -> Scala SDK enter image description here

Upvotes: 0

Mario Galic
Mario Galic

Reputation: 48400

Personally I setup a quick hello world app in IntelliJ in the following manner

  1. Execute sbt new scala/scala-seed.g8 to get the correct project structure
  2. Point IntelliJ to the newly created hello world via File | Open
  3. When prompted for Import Project from sbt settings I select Use sbt shell for both imports and builds, so I get the same build behaviour in IntelliJ and system terminal.
  4. Finally I right-click on Hello.scala and Run 'Hello' to automatically setup run configuration.

Upvotes: 1

pme
pme

Reputation: 14803

The simplest way is maybe to create a new Project and then copy your code.

  • Go to Files > New > Project..
  • Select sbt

new project

  • And add Name and Location.
  • Copy your files in yourProject/src/main/scala

  • Now your HelloWorld should like this:

run hello

  • Right click on the green Arrow, and run the program.
  • This will create automatically a Start configuration.

Upvotes: 2

Related Questions