
Over the past year I've been gradually learning Scala and I think it's fantastic! So I'm incredibly excited that [Scala now runs on Heroku][1]! Of course you can use the standard [Java on Heroku][2] / Maven method of running Scala on Heroku. But as of today you can also use [sbt][3] (the Scala Build Tool) to run Scala apps on Heroku. If you are new to Heroku, it is a Polyglot Cloud Application Platform. Put very simply:

**Heroku = Polyglot + Platform as a Service (PaaS) + Cloud Components**

If you want to try out Scala on Heroku, here are a few quick steps to get you started:

  1. [Create a Heroku account][4]
  2. Install the Heroku command line client on [Linux][5], [Mac][6], or [Windows][7].
  3. Install [git][8] and setup your SSH key
  4. Install [sbt][9] 0.11.0
  5. Login to Heroku from the command line:
    ```bash
    heroku auth:login
    ```

  6. Create a file named _build.sbt_ containing:
    ```scala
    scalaVersion := "2.9.1"

    {
      val stage = TaskKey[Unit]("stage", "Prepares the project to be run, in environments that deploy source trees rather than packages.")
      stage in Compile := {}
    }
    ```
    
    This adds the "stage" task which is used for the build on Heroku.
    
    * Create a _project/build.properties_ file containing:
    ```
    sbt.version=0.11.0
    ```
        
    This tells sbt which version of sbt to use.
        
    * Create a very simple Scala app in _src/main/scala/Hello.scala_ containing:
    ```scala
    object Hello extends App {
      println("hello, world")
    }
    ```
        
    * Test the app locally by running:
    ```bash
    sbt run
    ```
            
    You should see something like:
            
    ```bash
    [info] Set current project to default-0c17d0 (in build file:/home/jamesw/projects/helloscala/)
    [info] Running Hello 
    hello, world
    [success] Total time: 1 s, completed Sep 7, 2011 4:17:01 AM
    ```
        
    * Create a _.gitignore_ file containing:
    ```
    target
    project/boot
    project/target
    ```
        
    * Create a git repo, add the files to it, and commit them:
    ```bash
    git init
    git add .
    git commit -m init
    ```
        
    * Create a new app on Heroku using the Cedar stack:
    ```bash
    heroku create -s cedar
    ```
        
    * Upload your app to Heroku using git:
    ```bash
    git push heroku master
    ```
        
    * Run the app on Heroku:
    ```bash
    heroku run "sbt run"
    ```
            
    Voilà! You just ran Scala on the Cloud! </li> </ol> 
            
    You can get the full code for this project on github:
  
    <https://github.com/jamesward/helloscala>
            
    That was a very simple example to get you started. Visit the [Heroku Dev Center][10] to continue learning about how to use Scala on Heroku. And let me know if you have any questions.

 [1]: http://blog.heroku.com/archives/2011/10/3/scala/
 [2]: http://www.jamesward.com/2011/08/25/heroku-adds-java-support
 [3]: https://github.com/harrah/xsbt
 [4]: http://heroku.com/signup
 [5]: http://toolbelt.herokuapp.com/linux/readme
 [6]: http://toolbelt.herokuapp.com/osx/download
 [7]: http://toolbelt.herokuapp.com/windows/download
 [8]: http://git-scm.com/
 [9]: https://github.com/harrah/xsbt/wiki/Setup
 [10]: http://devcenter.heroku.com/tags/scala

