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

Can't figure out how to specify a main class. #61

Closed
hartleys opened this issue Nov 26, 2012 · 6 comments
Closed

Can't figure out how to specify a main class. #61

hartleys opened this issue Nov 26, 2012 · 6 comments

Comments

@hartleys
Copy link

I'm sure I must be doing something wrong, but I can't for the life of me figure out what. I've stripped it down to as simple as possible, but it still doesn't work.

I keep getting this error when I try to run the jar files:

Error: Could not find or load main class runner.runner

The build.sbt and plugins.sbt files were exactly as in your example at:
https://github.com/sbt/sbt-assembly
except build.sbt is:

import AssemblyKeys._
assemblySettings
jarName in assembly := "MyScalaUtils.jar"
mainClass in assembly := Some("runner.runner")

Here's my src directory layout:

$ ls -R src
src:
helloWorldTest  runner

src/helloWorldTest:
helloWorld.scala

src/runner:
runner.scala

runner.scala is just:

package runner

class runner {
  def main(args: Array[String]){
    println("Starting run.");
    helloWorldTest.helloWorld.run(args);
    println("Done.");
  }
}

What the heck is going wrong here?

@eed3si9n
Copy link
Member

Try putting your sources under src/main/scala/.

@hartleys
Copy link
Author

That worked. Sorry for the trouble!

PS. For anyone else having this problem and/or attempting to replicate. The package runner also has to be changed to:

package runner
object runner {
  def main(args: Array[String]){
    println("Starting run.");
    helloWorldTest.helloWorld.run(args);
    println("Done.");
  }
}

@robinloxley1
Copy link

I have same problem. I am running for java, and I put my code under src/main/java//. I can see the Main-Class entry has been written into META-INF/MANIFEST.MF. But it still complains by not finding main class. I can do java -cp however.

@yishenggudou
Copy link

I Got this error too

@kindlychung
Copy link

Same issue here.

java -jar complains about main class not found, java -cp x.jar path.to.Main works.

@nob13
Copy link

nob13 commented Feb 20, 2020

Same issue here.

java -jar complains about main class not found, java -cp x.jar path.to.Main works.

For google: Perhaps it's a problem like this: https://stackoverflow.com/a/46287790

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

No branches or pull requests

6 participants