"Error: Could not find or load main class" when trying to launch Run Configuration in Intellij

StephenBoesch

In a project that was originally set up for python I do have both python and java SDK's defined:

enter image description here

I am attempting to run a scala program: and the src directory is correctly marked as sources:

enter image description here

The class itself does have a main :

enter image description here

But the Intellij does not provide assist for setting up a Run Configuration - which should have been available by right click/context menu. So I set it up manually:

enter image description here

But when trying to actually run the program it is not successful saying Error: Could not find or load main class com.blazedb.algos.CourseraAlgos:

enter image description here

Update: for reference purposes here is a Run Configuration from a similar project that does work. I do not see any structural differences between the two.

enter image description here Any ideas why Intellij does not recognize the file as a scala class?

StephenBoesch

In addition to the steps shown above I had also tried:

  • adding a new scala-specific module
  • nuking and recreating the IJ project

These did not resolve the issue. It turns out the problem is that there were no pom.xml in this project. The resulting behavior by Intellij made it difficult to trace down the root cause: there was no message like

You need a pom.xml or a build.sbt to proceed

Apparently stray scala classes (dissociated from a formal build) are only haphazardly supported in Intellij.

So finally the answer is to create a new scala based project. Adding scala back to a project built for python is at the least unreliable and maybe not possible at all.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive