Reputation: 121
The problem is that when I open "cmd.exe" and go to the directory called chesschallenge6 to enter "sbt" command and "run" afterwards it doesn't work. I get an error message saying there is no main class specified. I checked if the main class name is the same as its file name and even tried "object ChessChallenge6 extends App" but it still didn't work. The solution is simple but I just don't see it.
└── _chesschallenge6
├── _project
├── _target
└── _src
├── _test
└── _main
├── _algorithm
├── _model
└── ChessChallenge6.scala
Upvotes: 4
Views: 13823
Reputation: 32240
I had this exact problem and the issue was that I was using a class
instead of an object
.
For example, make sure your main class is not like this:
class ChessChallenge6 {
def main(args: Array[String]): Unit = {
println("hello")
}
}
Instead, it should be:
object ChessChallenge6 {
def main(args: Array[String]): Unit = {
println("hello")
}
}
Notice that the first word is object and not class.
Upvotes: 4
Reputation: 15457
Your question is somewhat unclear. Here are my best guesses as to what is wrong:
Please ensure that your scala file is in "src/main/scala/ChessChallenge6.scala
", relative to the directory in which you run sbt
.
I am not sure if you are using underscores in your directory names, or if that is some kind of formatting that you are using only in the question text. If you are using underscores, you will need to remove them (or configure sbt
to look in non-standard directories for your sources).
If you are not using them, you should remove them from the question text, as they are confusing. (If you want to distinguish files from directories in a listing, a common convention is to add "/" to the end of a directory name, e.g. "src/
".)
See http://www.scala-sbt.org/0.13/docs/Directories.html
You must run sbt
in the directory above src
. In the latest version of your question, that would be in the chesschallenge6
dir.
Upvotes: 12