Question about running Scala programs from ScalaEdit

3 views
Skip to first unread message

david.matuszek

unread,
Nov 15, 2011, 9:36:40 AM11/15/11
to ScalaEdit
Hi,

I'm a relative novice to Scala programming, and as yet I don't know
SBT at all.

I'm trying out ScalaEdit, and it looks as though I should be able to
run my Scala program in the Scala Terminal that is provided. I would
expect a "Run" button or something. Since there isn't one, I'm
guessing that I'm supposed to somehow use SBT to do this?

So, simple question. I have a program in the edit window; how do I run
it?

I've been using Eclipse, so maybe I'm expecting something that isn't
there?

Thanks,
Dave

Kjell

unread,
Nov 15, 2011, 10:33:17 AM11/15/11
to ScalaEdit
Hi Dave,
Even though you could definitely run small programs in the Scala
Terminal, it is not build for that. The main purpose of it is to make
it possible to paste or type in expressions and see what they evaluate
to. If you write programs that consists of more than one file then sbt
is the perfect tool. Here are some simple steps that will let you get
started with ScalaEdit and the sbt terminal:
1. Select an empty directory where you want to store your project
files with the menu item "Project->Change Root..."2. If it is not
already done you can make the file list to the left autorefresh by
selecting "Project->Auto Refresh"3. Start an sbt terminal with
"Terminal->SBT Terminal->Version 0.11"4. Sbt will now initialize a
project folder in the folder you have selected. The target directory
will contain the compiled classes.5. Use "File->New" to start editing
the first file.6. Save the file (by pressing the save button or
Control-s) as "HeloWorld.scala" in the default directory.7. Paste in
the following content to the file:object HelloWorld{ def
main(args:Array[String]){ println("Hello World") }}8. Save the file9.
Run the HelloWorld program by pressing the run button in the sbt
terminal. If it works you will see Hello World printed out to the
terminal.
Tip: sbt is a very powerfull tool when developing Scala applications,
so it is worth spending some time to get to know it (https://
github.com/harrah/xsbt/wiki). All Scala compile errors that sbt detect
will show up in the list on the right hand side of the terminal and
the lines with errors will also be marked in the editor.

/Kjell

Kjell Winblad

unread,
Nov 15, 2011, 10:40:26 AM11/15/11
to ScalaEdit
Sorry, the message above was not very well formatted (thanks to google
groups :) ). This looks better:

Hi Dave,

(https://github.com/harrah/xsbt/wiki). All Scala compile errors that


sbt detect will show up in the list on the right hand side of the
terminal and the lines with errors will also be marked in the editor.

/Kjell

david.matuszek

unread,
Nov 15, 2011, 9:29:26 PM11/15/11
to ScalaEdit
Thanks, Kjell, that's the information I needed.

I'm not planning any large Scala projects, nothing over a couple
hundred lines, maybe two or three classes, so that's not an issue.

SBT is on my list of things I need to learn, right after GIT (I'm a
Mercurial person, myself, but it's losing out to GIT). Right now,
though, all my study time is spent improving my knowledge of Scala. A
"do this, then do that" method such as you gave me is what I need
right now; I'll understand it later.

Thanks again,
Dave

Kjell Winblad

unread,
Nov 16, 2011, 5:21:48 AM11/16/11
to scala...@googlegroups.com
When I tested my own description I found an error that will make it
not work. The file name containing the object with the main method
must have the same name as the object "HelloWorld.scala" and not
"HeloWorld.scala" as in the description. sbt will not find any class
containing a main method otherwise.
Reply all
Reply to author
Forward
0 new messages