I’m trying a Hello World Scala app using Play from the book, Scala Reactive Programming. When I try to run the app, it gives me “java.lang.RuntimeException: No main class detected.”. I’ve spent a ton of time on Google but haven’t found a working solution.
Solution 1:
This statement in build.sbt “lazy val usuallyCalledRoot = project.in(file(”."))". I still get the same error.
Solution 2:
This command, “sbt server/run”. That doesn’t even seem to be valid command. “sbt run” gives me the original error, and “sbt server” isn’t a valid command.
Sounds like the Play plugin is not loaded. How did you install it? Did you download the Play app as a package? Or did you add it to your SBT project files?
routes:
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~# HelloWorldController without using Play DI
GET /helloWorld controllers.HelloWorldNoDIController.helloWorld
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
Right, so I think the easiest way to get everything you need to get going with that code is, after installing sbt, is to run the following at the command line: sbt new playframework/play-scala-seed.g8
You will get a whole starter framework for your Play application. That is, from what you posted, you are still missing several items, including the directory structure, all of which are important to actually seeing your app show up running on http://localhost:9000 when you run it.
Once you see the basic app working, you can find the right places to paste the code you pasted from that example.