使用 Scala 2.8.0b 的 Eclipse 3.5 中出现 Scala 错误,“令牌字符串上的语法错误”

发布于 2024-08-09 15:15:33 字数 1051 浏览 4 评论 0 原文

我似乎缺少图书馆,但我不确定。

在这个文件中:

object Test {
    def main(args: Array[String]) {
        for (arg <- args)
            println(arg)
    }
}

我不确定是什么导致了这些错误:

Description Resource    Path    Location    Type
Syntax error on token "object", interface expected  TestSrc.scala   /ScalaDataMiningFunctions/src   line 1  Java Problem
Syntax error on token "String", delete this token   TestSrc.scala   /ScalaDataMiningFunctions/src   line 2  Java Problem
Syntax error on token ":", delete this token    TestSrc.scala   /ScalaDataMiningFunctions/src   line 2  Java Problem
Syntax error on token "<", ( expected   TestSrc.scala   /ScalaDataMiningFunctions/src   line 3  Java Problem

我可能只需要完成这些步骤并在 Netbeans 中执行此操作,但我更愿意找出发生了什么。

在我使用maven创建的lift项目中,我没有这些错误,但是有很多我的jar文件中没有。

一个 jar 文件是 scala-compiler-2.7.3.jar,它位于 lift 项目中,但不在我的 scala 项目中。

我的 scala 项目中唯一的库是 Scala Library version 2.8.0r19106-...JRE System Library [jre1.6.0_07]

I seem to be missing libraries but I am not certain.

In this file:

object Test {
    def main(args: Array[String]) {
        for (arg <- args)
            println(arg)
    }
}

I am not certain what leads to these errors:

Description Resource    Path    Location    Type
Syntax error on token "object", interface expected  TestSrc.scala   /ScalaDataMiningFunctions/src   line 1  Java Problem
Syntax error on token "String", delete this token   TestSrc.scala   /ScalaDataMiningFunctions/src   line 2  Java Problem
Syntax error on token ":", delete this token    TestSrc.scala   /ScalaDataMiningFunctions/src   line 2  Java Problem
Syntax error on token "<", ( expected   TestSrc.scala   /ScalaDataMiningFunctions/src   line 3  Java Problem

I may just need to go through the steps and do this in Netbeans instead, but I would prefer to find out what is going on.

In my lift project, which was created by using maven, I don't have these errors, but there are many jar files there that I don't have in mine.

One jar file is scala-compiler-2.7.3.jar that is in the lift project but not in my scala project.

The only libraries in my scala project are Scala Library version 2.8.0r19106-... and JRE System Library [jre1.6.0_07]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

ζ澈沫 2024-08-16 15:15:33

Eclipse 将您的 Scala 源视为 Java 并对其感到窒息(线索是每个问题报告末尾的文本“Java Problem”)。

您很可能没有启用 JDT Weaving(或未成功启用),因此请按照此处的故障排除说明进行操作,

http://scala-ide.assembla.com/wiki/show/scala-ide/Troubleshooting

如果您仍然遇到问题,请跟进 scala-ide-用户列表,

http://groups.google.com/group/scala-ide-user

Eclipse is seeing your Scala sources as Java and choking on them (the clue is the text "Java Problem" at the end of each problem report).

Most likely you don't have JDT Weaving enabled (or not enabled successfully), so please follow the troubleshooting instructions here,

http://scala-ide.assembla.com/wiki/show/scala-ide/Troubleshooting

and if you still have issues, please follow up on the scala-ide-user list,

http://groups.google.com/group/scala-ide-user

菊凝晚露 2024-08-16 15:15:33

Eclipse 的 scala 插件还很不成熟。如果您没有锁定 Eclipse,我建议您尝试一下更稳定的 netbeans 插件。 :)

The scala plugin for Eclipse is still quite immature. If you are not locked into eclipse i would advise you to try out the netbeans plugin which is alot more stable. :)

霞映澄塘 2024-08-16 15:15:33

请安装scala插件到eclipse
添加以下站点

http://download.scala-ide.org/update-current-35< /a>

它会起作用...

please install scala plugin to eclipse
add following site

http://download.scala-ide.org/update-current-35

it will work...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文