score:22
I think this should be your folder structure
Scala0
└── src
└── main
└── scala
└── com.ks.sparkscala
└── FriendsByAge
In your case create a folder main/scala inside src and copy the package inside it.
Please follow here for the project structure
I hope this helped!
score:0
I had a similar problem. I’ve got Could not find or load main class
in IJIdea IU-182.4892.20 / Scala 2.13
for .scala
file with such structure:
package ...
import ...
object Main extends App {
...
}
//other traits, classes, objects
But when I moved //other traits, classes, objects
to the separate .scala
file in the same package my problem was solved.
score:0
I was experiencing the same error message and the below solution worked for me:
- Right-click on the project.
- Click on Scala.
- Choose the option "Set the scala installation".
- Select the Scala Installation (I selected "Fixed Scala Installation: 2.10.6(bundled").
After this, it ran fine and did not give that error message.
score:0
Another one solution. I had a similar problem on project with Scala + SBT.
How I solved this one:
- Run my project via SBT like this: sbt my-project/run
- Stopped it (Ctrl+C)
- Run debug -- it works again.
score:0
There were numerous things I need to solve this problem, and I think every one of them was important.
- Make sure the scala file in question is in the "src" folder.
- Make sure it is an object (if your inner class/object is an object).
- Make sure the filename and the class/object name is the same.
(The following instructions work in IntelliJ)
If #1 is not true, here's the easiest way to fix it:
- Click and drag your file into the "src" folder in IntelliJ. Say "yes" to any refactorings.
If #2 or #3 is not true, here's the easiest way to fix it:
- Copy your code (CTRL+A, CTRL+C)
- Right-click your "src" folder and select "New Scala class"
- Type in the name of your class / object
- Select "Object" if your file will contain a top-level object instead of a top-level class
- Press ENTER (or select the appropriate confirmation button)
- Paste in your code (CTRL+A, CTRL+V);
RESULT: Now you should have a file called "YourClass.scala" in your "src" folder, and it should have an orange icon if it's an object. The filename should match the name of the toplevel class/object. And you should be able to right-click it and run it. And then after you do that, you should be able to just press the play button in the top right corner. And it should work.
score:1
score:1
As far I can see your package structure is com.ks.sparkscala which is different from the declared one in FriendsByAge.scala, com.sundogsoftware.spark Hope this helps.
score:1
For the reference of the IntelijIDEA I guess somehow you would be using the scala plugin, in that case, there is a fix to the above-mentioned question:
Error: Could not find or load main class in both Scala IDE https://youtrack.jetbrains.com/issue/SCL-13636
Try to reimport the project and overwrite the .idea directory as while importing as a Existing Project it will prompt to overwrite the .idea configuration. Hope that Fix
FYI Its a UNRESOLVED issue
score:4
In the eclipse -->project properties-->scala compiler ---> change the scala installation.
It is working for me .
Source: stackoverflow.com
Related Query
- Scala Error: Could not find or load main class in both Scala IDE and Eclipse
- Could not find or load main class in scala in intellij IDE
- 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
- Scala - IntelliJ IDEA Error: Could not find or load main class
- Could not find or load main class (classname) in Scala Intellij
- Error: Could not find or load main class with Spark in Eclipse
- Dockerize a scala app: Could not find or load main class
- Intellij IDEA Error: Could not find or load main class org.jetbrains.jps.cmdline.Launcher in Scala Project
- 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
- New scala project in Intellij - Error: Could not find or load main class
- Scala bazel Error: Could not find or load main class
- Error: Could not find or load main class ... in eclipse
- Gatling Error: Could not find or load main class Engine
- Scala IDE Error -could not find/load main class
- Scala Main Class not found in Eclipse ide
- "Could not find or load main class" error for Gradle-generated Scala JAR
- Eclipse scala "Could not find or load main class"
- 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 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
More Query from same tag
- How to make implicit conversion work during pattern matching
- instantiate mix traits is compiling while single trait is not
- Summoning Scala implicits for subclasses of sealed abstract trait
- Performing a groupBy on a dataframe while limiting the number of rows
- How can I publish or subscribe to a materialized Akka Stream flow graph?
- How to remove non-ascii characters from logs?
- combineByKey on a Dstream throws an error
- Spray.io: When (not) to use non-blocking route handling?
- How to make covariant in scala a java generic method with a parameterized return type
- How can I differentiate between def foo[A](xs: A*) and def foo[A, B](xs: (A, B)*)?
- Disable automatic generation of opening parenthesis in scala by Intellij
- Scala abstract types in classes within objects
- scala for comprehension throwing error for Map
- how to pass multipleColumns transformation rules from XML file to Dataframe in Spark?
- compilation error when a SIRD is added in the Play application
- Access specific row from spark dataframe
- Can someone explain me implicit conversions in Scala?
- Compare values of multiple columns based on column identifier
- How can i compile java record with scala code?
- How to drop malformed rows while reading csv with schema Spark?
- Spark: how to not use aws credentials explicitly in Spark application
- Returning an Ordered[T] from a method in Scala
- stuck with futures in scala
- Cannot connect locally to hdfs kerberized cluster using IntelliJ
- Scala Futures for-comprehension with a list of values
- Is this a bug in Scala 2.9.1 lazy implementation or just an artifact of decompilation
- overwrite hive partitions using spark
- Scala Iterator.takeWhile is dropping the failed element
- Why does merging with empty fs2.Stream change program's behavior
- Spark scala :FIle already exists exception while Uploading csv file to azure blob