score:21
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.
If you still wanna make it manually your configuration should work. That's my Run configuration that works:
score:-1
score:0
Had a similar problem with latest Intellij IDEA build (2022.1.1) and scala 3.1.2 - both sbt and Intellij scala projects. For me the solution was to use non-ascii path.
score:1
Create a new project and make sure SBT is proper loaded along with Scala Library. This happens with many times, bad internet connection or failure of Scala library/SBT loading might be some of the reasons. Best of Luck for Next Project, Happy Developers & Coders.
score:2
score:3
In my case the object
in the object MyObject extends App
was nested, if you have it unested meaning in your scala file it's not under any other object it made it work.
Netsted caused this error in intellij:
object External {
object MyMain extends App // Could not find or load main class in scala in intellij IDE
}
While the below unested worked:
object External { }
object MyMain extends App // Worked!
score:7
You will get this error if you tried to open the project and imported it incorrectly. I would open the project like this in Intellij:
File>New> Project from Existing Source>(select) Import project from external model>
(select)sbt
click Next>Finish
score:40
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
Source: stackoverflow.com
Related Query
- Could not find or load main class in scala in intellij IDE
- Scala Error: Could not find or load main class in both Scala IDE and Eclipse
- Scala - IntelliJ IDEA Error: Could not find or load main class
- Could not find or load main class (classname) in Scala Intellij
- Intellij IDEA Error: Could not find or load main class org.jetbrains.jps.cmdline.Launcher in Scala Project
- New scala project in Intellij - Error: Could not find or load main class
- Dockerize a scala app: Could not find or load main class
- Error: Could not find or load main class Main Scala
- Kafka 8.2.0 on Scala 2.10/Windows - Could not find or load main class org.apache.zookeeper.server.quorum.QuorumPeerMain
- Error: Could not find or load main class in scala
- Scala jar: Error: Could not find or load main class
- Scala bazel Error: Could not find or load main class
- Reason and fix for "Error: Could not find or load main class Anne" on Scala Getting started tutorial
- Error when building Scala Maven project: Could not find or load main class scala_maven_executions.MainWithArgsInFile
- Gatling Error: Could not find or load main class Engine
- Scalatra could not find or load main class
- SparkSession throw Could not find or load main class
- Could not find or load main class org.scalatest.tools.Runner
- Error: Could not find or load main class with Spark in Eclipse
- Error: Could not find or load main class io.gatling.app.Gatling
- Could not find or load main class com.weekdays.claobj.Ann1
- Error: Could not find or load main class com.sundogsoftware.spark.RatingsCounte
- How to fix 'Error: Could not find or load main class' on scala application in Intellij?
- Could not find or load main class sbt-assembly executable jar
- Error: Could not find or load main class scala.tools.nsc.Main
- Could not find or load main class Platform during docker container running
- Could not find or load main class Spark Docker
- Error: Could not find or load main class com.sparkarma.spark.WordCount
- Error: Could not find or load main class Files\Eclipse Caused by: java.lang.ClassNotFoundException: Files\Eclipse
- Error: Could not find or load main class: Scala IDE/Spark
More Query from same tag
- How can I benchmark performance in Spark console?
- import scala.io.StdIn
- Trying to make a HCons List CaseClassShape
- Getting the String out of a Gatling expression
- Is it possible to have two priority queues "in sync" in Scala?
- Scala sortBy parameters as sequence
- Implicits using structural types
- Java/Scala Required: Iterable[_ <: Float], found: Iterable[Float]
- Idiomatic Event engine in Scala
- Common Template Library
- How to use flatMapValues on Kafka
- Writing XML literal as a parameter in Scala
- Matching type of head/tail pattern match argument
- Performing aggregate function on a date range
- How to start Play application before tests and then shut it down in specs2?
- Why do I have to cast elements of RDD[Int] when sorting?
- How to concatenate function arguments and return values using shapeless
- How to remove extra Escape characters from a text column in spark dataframe
- Table is not Found while testing with H2Database
- How to change the code from Scala to Python
- How to avoid java.lang.OutOfMemoryError Exception when calculating all possible combinations in Scala?
- What does it mean 'List(1, 2, 3)' in Scala?
- Spark: computationally efficient way to compare dates?
- When is it appropriate to use a Scala Extractor?
- Solution for Spark Plan Growing too Large and Job Erroring out
- How to encode categorical features in Apache Spark
- Is it optional to import Java packages in Scala?
- ChannelOutputShutdownException on spark streaming queries
- Spark submit hangs after writing from Cassandra to json
- How to extract the field values from a dataset in spark using scala?