title: How to run an existing Scala project using VS Code and Metals?
body: <p>I am brand new to Scala and I find that <a href="http://scala-ide.org/" rel="nofollow noreferrer">Scala IDE</a> is very slow on my machine for basic things like searching the codebase and editing code. I am used to Visual Studio Code and was very happy to find <a href="https://marketplace.visualstudio.com/items?itemName=scalameta.metals" rel="nofollow noreferrer">this metals extension</a>.</p>
  
  <p>I was able to "import build" and fix issues like bumping up scala version in my projects but I am not sure how to reproduce this step to set up a run configuration and actually launch our app in Scala IDE. </p>
  
  <p><a href="https://i.stack.imgur.com/ignqW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ignqW.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/JABnf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JABnf.png" alt="enter image description here"></a></p>
  
  <p>We have a parent folder which has a bunch of projects and a 'consoleapp' project which is the main entry point of our app - it imports the logic/routes of all other projects.</p>
  
  <pre><code>|____parent
  | |____consoleapp
  | |____project1
  | |____project2 
  </code></pre>
  
  <p>I tried <code>sbt run</code> and <code>sbt runMain consoleapp</code> from within the consoleapp folder and also the parent folder but they didn't work.</p>
  
  <p>I am not sure what other information from our setup is relevant - happy to provide more info as needed.</p>
  
  <p><strong>Updated</strong> to add more details below:</p>
  
  <p><strong>consoleapp/build.sbt</strong></p>
  
  <pre><code>name := "consoleapp"
  
  version := "1.0"
  
  scalaVersion := "2.12.10"
  
  packMain := Map("consoleapp" -&gt; "consoleapp")
  
  libraryDependencies ++=  Seq (...)
  </code></pre>
  
  <p><strong>Output of commands I ran - <code>sbt run</code> and <code>sbt runMain</code></strong></p>
  
  <p>Running from ~/scala/parent</p>
  
  <pre><code>&gt; sbt run                                                                                                                                                                 masterstate [0a8dab85] modified
  [info] Loading settings for project global-plugins from metals.sbt,build.sbt ...
  [info] Loading global plugins from /Users/pradhyo/.sbt/1.0/plugins
  [info] Loading project definition from /Users/pradhyo/scala/parent/project
  [info] Loading settings for project consoleapp from build.sbt ...
  ... 
  Loading settings for all other projects in parent folder
  ...
  [info] Loading settings for project parent from build.sbt ...
  [info] Resolving key references (22435 settings) ...
  [info] Set current project to parent (in build file:/Users/pradhyo/scala/parent/)
  [error] java.lang.RuntimeException: No main class detected.
  [error]     at scala.sys.package$.error(package.scala:30)
  [error] stack trace is suppressed; run last Compile / bgRun for the full output
  [error] (Compile / bgRun) No main class detected.
  [error] Total time: 1 s, completed 18-Dec-2019 1:41:25 PM
  </code></pre>
  
  <p>Running from ~/scala/parent</p>
  
  <pre><code>&gt; sbt "runMain consoleapp.consoleapp"                                                                                                                                     masterstate [0a8dab85] modified
  [info] Loading settings for project global-plugins from metals.sbt,build.sbt ...
  [info] Loading global plugins from /Users/pradhyo/.sbt/1.0/plugins
  [info] Loading project definition from /Users/pradhyo/scala/parent/project
  [info] Loading settings for project consoleapp from build.sbt ...
  ... 
  Loading settings for all other projects in parent folder
  ...
  [info] Loading settings for project parent from build.sbt ...
  [info] Resolving key references (22435 settings) ...
  [info] Set current project to parent (in build file:/Users/pradhyo/scala/parent/)
  [info] running consoleapp.consoleapp 
  [error] (run-main-0) java.lang.ClassNotFoundException: consoleapp.consoleapp
  [error] java.lang.ClassNotFoundException: consoleapp.consoleapp
  [error]     at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
  [error] stack trace is suppressed; run last Compile / bgRunMain for the full output
  [error] Nonzero exit code: 1
  [error] (Compile / runMain) Nonzero exit code: 1
  [error] Total time: 0 s, completed 18-Dec-2019 1:46:21 PM
  </code></pre>
  
  <p>Running from ~/scala/parent/consoleapp</p>
  
  <pre><code>&gt; sbt run                                                                                                                                                                 masterstate [0a8dab85] modified
  [info] Loading settings for project global-plugins from metals.sbt,build.sbt ...
  [info] Loading global plugins from /Users/pradhyo/.sbt/1.0/plugins
  [info] Loading project definition from /Users/pradhyo/scala/parent/consoleapp/project
  [info] Loading settings for project consoleapp from build.sbt ...
  [info] Set current project to consoleapp (in build file:/Users/pradhyo/scala/parent/consoleapp/)
  [error] java.lang.RuntimeException: No main class detected.
  [error]     at scala.sys.package$.error(package.scala:30)
  [error] stack trace is suppressed; run last Compile / bgRun for the full output
  [error] (Compile / bgRun) No main class detected.
  [error] Total time: 0 s, completed 18-Dec-2019 1:49:26 PM
  </code></pre>
  
  <p>Running from ~/scala/parent/consoleapp</p>
  
  <pre><code>&gt; sbt "runMain consoleapp"                                                                                                                                                masterstate [0a8dab85] modified
  [info] Loading settings for project global-plugins from metals.sbt,build.sbt ...
  [info] Loading global plugins from /Users/pradhyo/.sbt/1.0/plugins
  [info] Loading project definition from /Users/pradhyo/scala/parent/consoleapp/project
  [info] Loading settings for project consoleapp from build.sbt ...
  [info] Set current project to consoleapp (in build file:/Users/pradhyo/scala/parent/consoleapp/)
  [info] running consoleapp 
  [error] (run-main-0) java.lang.ClassNotFoundException: consoleapp
  [error] java.lang.ClassNotFoundException: consoleapp
  [error]     at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
  [error] stack trace is suppressed; run last Compile / bgRunMain for the full output
  [error] Nonzero exit code: 1
  [error] (Compile / runMain) Nonzero exit code: 1
  [error] Total time: 1 s, completed 18-Dec-2019 1:50:06 PM
  </code></pre>