Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find or load main class in scala in intellij IDE

I have searched for this error, but the answers were for Java, but my case is Scala. I am trying to run this project in IntelliJ IDE sentimenAnalysis, but it throws an error. This is also the structure of the project. Class Not found

Update 1 According to answers, Adding $ at the end of the name of search class enter image description here

Update 2 after adding sbt task: enter image description here

Update 3 My problem was resolved by importing the project, instead of getting it directly from GitHub, probably the manual configuration that Mike Allen said could resolve the problem, but I couldn't successfully apply that.

like image 454
sariii Avatar asked May 24 '17 16:05

sariii


People also ask

How do I get Scala class in IntelliJ?

On the Project pane on the left, right-click src and select New => Scala class. If you don't see Scala class, right-click on HelloWorld and click on Add Framework Support…, select Scala and proceed. If you see Error: library is not specified, you can either click download button, or select the library path manually.


2 Answers

My problem was resolved when I marked src folder as sourced root. Click with the right button in src folder -> Mark Directory as -> Sources root

like image 187
Laura Corssac Avatar answered Sep 21 '22 19:09

Laura Corssac


Probably you imported project somehow wrong. I see scala folder is not highlighted as sources. Usually, you don't even need to setup Run configuration manually for Scala SBT project. Do you have Scala and SBT Plugins in your IDE?

You should open SBT projects through "Import project" and choose "build.sbt" file. I would also recommend enabling auto-import to install all of the dependicies.

That's how it look for me: Here how it looks for me

If you still wanna make it manually your configuration should work. That's my Run configuration that works:

My run configuration

like image 31
SeriousDron Avatar answered Sep 19 '22 19:09

SeriousDron