我不知道你正在使用的SBT的版本,或者你用什麼項目設置,但通常你的hw.scala文件應該放在src/main/scala目錄中以便找到它。另外,正如synesso所言,scala運行時似乎不存在。通常sbt只會在創建新項目時下載這些內容。 我只是試圖在一個FRES項目中使用SBT 0.7.3,而這個作品:
$ sbt
Project does not exist, create new project? (y/N/s) y
Name: test
Organization: test
Version [1.0]:
Scala version [2.7.7]:
sbt version [0.7.3]:
Getting Scala 2.7.7 ...
:: retrieving :: org.scala-tools.sbt#boot-scala
confs: [default]
2 artifacts copied, 0 already retrieved (9911kB/26ms)
Getting org.scala-tools.sbt sbt_2.7.7 0.7.3 ...
:: retrieving :: org.scala-tools.sbt#boot-app
confs: [default]
15 artifacts copied, 0 already retrieved (4023kB/25ms)
[success] Successfully initialized directory structure.
[info] Building project test 1.0 against Scala 2.7.7
[info] using sbt.DefaultProject with sbt 0.7.3 and Scala 2.7.7
> exit
$echo 'object Hi { def main(args: Array[String]) { println("Hi!") } }' > src/main/scala/hw.scala
> sbt
[info] Building project test 1.0 against Scala 2.7.7
[info] using sbt.DefaultProject with sbt 0.7.3 and Scala 2.7.7
> run
Hi!
> package
[info]
[info] == compile ==
[info] Source analysis: 0 new/modified, 0 indirectly invalidated, 0 removed.
[info] Compiling main sources...
[info] Nothing to compile.
[info] Post-analysis: 2 classes.
[info] == compile ==
[info]
[info] == package ==
[info] == package ==
[success] Successful.
我不能運行的第一個,我沒有安裝斯卡拉(SBT下載它,並利用內部)。第二個不起作用。 – 2010-05-22 10:01:31
java -cp project/boot/scala-2.7.7/lib/scala-library.jar :. -jar target/scala_2.7.7/test_2.7.7-1.0.jar您好 #不工作。 – 2010-05-22 10:03:02
您不能將-cp和-jar與java可執行文件混合在一起。將你的test_2.7.7-1.0.jar包含在classpath中。如果你在窗戶上,分隔符是;不是: 因此,請嘗試: java -cp project/boot/scala-2.7.7/lib/scala-library.jar:target/scala_2.7.7/test_2.7.7-1.0.jar您好 – Synesso 2010-05-22 11:34:46