Create new scala project sbt

Here are the steps to create a new Scala project using SBT:

Step 1: Install SBT

If you haven't already, install SBT (Simple Build Tool) on your machine. You can download the installer from the official SBT website: https://www.scala-sbt.org/download.html

Step 2: Create a new directory for your project

Create a new directory for your project, for example, my-scala-project.

Step 3: Initialize the project with SBT

Open a terminal or command prompt and navigate to the new directory:

cd my-scala-project

Then, run the following command to initialize the project with SBT:

sbt new scala/scala-seed.g8

This will create a basic SBT project structure with a build.sbt file and a src directory.

Step 4: Edit the build.sbt file

Open the build.sbt file in your favorite editor and update the name and version settings to match your project's information:

name := "My Scala Project"
version := "1.0"

You can also add other settings, such as dependencies, plugins, and tasks, as needed.

Step 5: Create a Scala source file

Create a new file called Main.scala in the src/main/scala directory:

package com.example

object Main {
  def main(args: Array[String]): Unit = {
    println("Hello, World!")
  }
}

This is a simple "Hello, World!" program in Scala.

Step 6: Compile and run the project

Compile the project using SBT:

sbt compile

This will create a target directory with the compiled classes.

Run the project using SBT:

sbt run

This will execute the Main object and print "Hello, World!" to the console.

That's it! You now have a new Scala project set up with SBT. You can continue to develop and build your project using SBT's various commands and features.