Scala Error: Could not find or load main class in

2019-01-26 13:56发布

问题:

Here is my problem, I know there are lots of answers for similar questions, however none of them worked after I tried. I'm using both Scala IDE 4.6 and eclipse Oxygen to run the code and all failed on this error.

Here's my scala compiler configuration:

Here is my run configuration:

Here is my code, file structure and error showed in console:

Here is the information Problem console:

From online answer, I have already tried to clean the project before building, I also tried all the versions of JVM and Scala compiler, all of those didn't help.

The code was directly import from a online course code, so I believe there shouldn't be any errors in the code.

回答1:

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!



回答2:

For Intellij IDE, use the following procedure:

  1. Go to the drop down at right top of window and select "Edit Configuration".

  2. On the pop-up screen, select "Scala-console" in left side, and in the right side, select your module name under "Use class path and SDK of module.



回答3:

In the eclipse -->project properties-->scala compiler ---> change the scala installation.

It is working for me .



回答4:

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.