console actions provide a means for running user code in
the same virtual machine as sbt.
run also exists in a variant called
runMain that takes an
additional initial argument allowing you to specify the fully
qualified name of the main class you want to run.
share the same configuration and cannot be configured separately.
This page describes the problems with running user code in the same virtual machine as sbt, how sbt handles these problems, what types of code can use this feature, and what types of code must use a forked jvm. Skip to User Code if you just want to see when you should use a forked jvm.
User code can call
System.exit, which normally shuts down the JVM.
console actions run inside the same JVM as sbt,
this also ends the build and requires restarting sbt.
User code can also start other threads. Threads can be left running
after the main method returns. In particular, creating a GUI creates
several threads, some of which may not terminate until the JVM
terminates. The program is not completed until either
called or all non-daemon threads terminate.
During deserialization, the wrong class loader might be used for various complex reasons. This can happen in many scenarios, and running under SBT is just one of them. This is discussed for instance in issues #163 and #136. The reason is explained here.