如何执行scala swing应用程序?
我是 scala 新手。并尝试执行 swing 应用程序。 我正在使用 scala 2.8 我已经成功编译了程序,但是.. 执行时显示错误,比如没有这样的文件.. 有谁可以帮我吗?
我提供了我正在尝试执行的代码。
Gui.scala
import swing._
object Gui extends SimpleSwingApplication
{
def top=new MainFrame {
title="swing"
val b1=new Button{
text = "ok"
}
}
}
scalac Gui.scala
它编译成功并创建类文件 但当我尝试时
scala Gui
它只是回复
没有这样的文件
i am new for scala .and trying to execute swing application.
I am using scala 2.8
I have compiled the program successfully but..
while executing it is showing the error like no such file..
can any 1 please help me out?
i m providing the code i am trying to execute.
Gui.scala
import swing._
object Gui extends SimpleSwingApplication
{
def top=new MainFrame {
title="swing"
val b1=new Button{
text = "ok"
}
}
}
scalac Gui.scala
it compiles successfully and create class file
but when I try
scala Gui
it just replies
No such File
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
设置:
编译:
执行:
应用程序启动。
Setup:
Compile:
Execute:
And the applications starts.
这不是从 Scala 代码中直接剪切和粘贴,因为
object Gui
和{
之间的空行会导致编译错误。现在,如果您修复该错误并使用 Scala 2.8 进行编译,您应该在本地目录中获取这些类:
如果如果你不这样做,那么要么编译失败,要么缺少其他东西。例如,如果您在顶部声明了一个
package X
(并将其从示例中删除),则Gui
将不会位于本地目录中,而是位于子目录下X,您应该通过输入 scala X.Gui 来调用它。另一种可能性是您有一些 Java 环境变量将输出目录指向其他位置。
This is not a direct cut&paste from the Scala code, as the blank line between
object Gui
and{
causes a compilation error.Now, if you fix that error and compile this with Scala 2.8, you should get these classes in the local directory:
If you don't, then either the compilation did not work, or there's something else missing. For example, if you declared a
package X
at the top (and removed it from the example), thenGui
won't be in the local directory, but under a subdirectory X, and you should invoke it by typingscala X.Gui
.Another possibility is that you have some Java environment variable pointing the output directory to someplace else.