1

I have a simple HelloWorld.scala file.

object Hello World {
   def main(arg: Array[String]) = {
       println("Hello World!")
   }
}

Normally, I run sbt, compile, run in my terminal. After setting breakpoints in IntelliJ, how do I get the breakpoints to actually trigger?

Ben
  • 127
  • 1
  • 10
  • `Hello World` is not a valid name for an object, you may use `HelloWorld` – Raphael Roth Oct 31 '16 at 07:28
  • Possible duplicate of [Debugging Scala code with simple-build-tool (sbt) and IntelliJ](http://stackoverflow.com/questions/4150776/debugging-scala-code-with-simple-build-tool-sbt-and-intellij) – Dima Oct 31 '16 at 11:19

2 Answers2

6

I do it normally like this:

First, set breakpoints by clicking in the editor.

enter image description here

select main method in the code, wait until the light-bulp shows up. In Its menu, you can choose "run".

enter image description here

This automatically creates a "run-configuration" for this class. After that, you should see the name of your Object in the upper-right select manue ("run configuration"), you can then just click the "bug"icon.

enter image description here

Raphael Roth
  • 26,751
  • 15
  • 88
  • 145
0

Intellij will allow you to setup a run configuration from within the IDE. Assuming you've imported the SBT project, right clicking on the main method/object should have a "debug" option in the context menu which would run the application from inside the IDE and that execution would stop at the breakpoints.

Alternatively, if you are tied to the SBT run, you can also try creating a run configuration for the SBT targets and debug that.

As an aside, this is the same process as for a Java application (or any other supported by the IDE)

Angelo Genovese
  • 3,398
  • 17
  • 23