Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find or load main class #12851

Closed
okarmusk opened this issue Jun 16, 2021 · 5 comments
Closed

Could not find or load main class #12851

okarmusk opened this issue Jun 16, 2021 · 5 comments

Comments

@okarmusk
Copy link

okarmusk commented Jun 16, 2021

I'm not sure but I found unexpected behavior after compilation Scala 3 code with SBT.
build.sbt looks like:

name := "scala-cheat-sheet"
version := "1.0"
scalaVersion := "3.0.0"

Compile/mainClass := Some("com.okarmusk.Main")

The main object is located under src/main/scala/com/okarmusk and looks like:

package com.okarmusk

object Main {
  def main(args: Array[String]): Unit = {
    println("Hello world!")
  }
}

I sequentially run commands:

  • sbt clean
  • sbt package
  • scala target/scala-3.0.0/scala-cheat-sheet_3-1.0.jar

As the result I obtained:

Error: Could not find or load main class target.scala-3.0.0.scala-cheat-sheet_3-1.0.jar
Caused by: java.lang.ClassNotFoundException: target.scala-3.0.0.scala-cheat-sheet_3-1.0.jar

Problem exists on scala 3 version Scala code runner version 3.0.1-RC1 -- Copyright 2002-2021, LAMP/EPFL, on scala 2 example works as expected.

OS: xubuntu 20.04
sbt: 1.5.2
scala: 3.0.1 RC

Issue exists also in official scala 3.0.0 version

It is worth to notice that when I run sbt run the program executes correctly.

@SethTisue
Copy link
Member

duplicate of #12569 ?

@okarmusk
Copy link
Author

If needed, you can pin it as duplicate, but in this issue I want to underline, that issue exists on pure scala 3 binary, not wrapped by snips sdk or any other stuff.
Btw I feel that topic #12569 died cause of no response...

@som-snytt
Copy link
Contributor

I'll update here if the fix is scala-only and not sbt. btw, snips is a dir name in my prompt.

@okarmusk
Copy link
Author

okarmusk commented Jun 16, 2021

I've created issue on sbt repo and it was redirect as scala 3 issue. For more information, please check #6541.
I've been terrified when I saw such kind of error, especially when I switched back to scala 2 and everything works.

@SethTisue
Copy link
Member

but in this issue I want to underline, that issue exists on pure scala 3 binary, not wrapped by snips sdk or any other stuff

(that would be appropriate as a comment on the other ticket)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants