【问题标题】:How to compile scala swing app?如何编译 scala swing 应用程序?
【发布时间】:2013-03-29 03:23:57
【问题描述】:

我正在使用:

% scalac -version
Scala compiler version 2.9.1 -- Copyright 2002-2011, LAMP/EPFL

在 Ubuntu 12.04 上。

这段代码保存在 HelloGui.scala 中:

import scala.swing._

object HelloGui extends SimpleSwingApplication {
  def top = new MainFrame {
    title = "Hello World GUI"
    contents = new Button {
      text = "Click me"
    }
  }
}

当我尝试编译时,我得到:

% scalac HelloGui.scala        
HelloGui.scala:1: error: object swing is not a member of package scala
import scala.swing._
             ^
one error found

我尝试过使用import swing._(从教程中不清楚我需要在这个版本的 scala 中使用哪个导入路径),我得到:

% scalac HelloGui.scala
HelloGui.scala:1: error: not found: object swing
import swing._
       ^
one error found

当我查看 /usr/share/java 时,我看到 scala-swing-2.9.1.jar 和 scala-swing.jar 作为它的符号链接,所以这些库似乎存在?

我是缺少编译器标志还是需要安装另一个包?

【问题讨论】:

    标签: scala scala-swing


    【解决方案1】:

    编译器需要明确传递swing jar 的路径。这有效:

    % scalac -classpath /usr/share/java/scala-swing.jar HelloGui.scala
    

    【讨论】:

      猜你喜欢
      • 2014-08-26
      • 1970-01-01
      • 2022-01-17
      • 1970-01-01
      • 2019-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-01
      相关资源
      最近更新 更多