Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8433835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:29:47+00:00 2026-06-10T06:29:47+00:00

I just started learning Scala, and as part of the process, I’ve been trying

  • 0

I just started learning Scala, and as part of the process, I’ve been trying to write some simple scripts that use Swing.

Here is an extremely stripped down example which exhibits the problem that I am seeing.

SimpleSwingApp:

import scala.swing._
object SimpleSwingApp extends SimpleSwingApplication {
  def top = new MainFrame {
    println ("Starting")
    title = "First Swing App"
    contents = new Button { text = "Click me" }
  }
}

When I run the script through the Eclipse Scala IDE as a Scala Application, everything works as expected. I get the expected “Starting” text printed to the Eclipse console and the little GUI pops up and waits for a click.

When I try to run it as a script from the command line, I get nothing.

> scala SimpleSwingApp.scala

No error message, no “Starting”, no GUI.

So what is going on, and how can I achieve the result that I want (ie, starting a Scala GUI script from the command line)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T06:29:49+00:00Added an answer on June 10, 2026 at 6:29 am

    The problem is that the Scala script runner is looking for a main method in your script file, but it isn’t finding one.

    The reason it isn’t finding one is because you are inheriting main from SimpleSwingApplication, so there isn’t a main method in your script file.

    You can work around the problem by adding a main method to your script that immediately invokes super.main, as follows:

    import scala.swing._
    object SimpleSwingApp extends SimpleSwingApplication {
    
      override def main(args: Array[String]) = super.main(args)
    
      def top = new MainFrame {
        println("Starting")
        title = "First Swing App"
        contents = new Button { text = "Click me" }
      }
    }
    

    Now, the script will not raise an error in the Scala IDE, and it can be executed by calling

    scala SimpleSwingApp.scala 
    

    rather than the less aesthetic

    scala -i SimpleSwingApp.scala -e "SimpleSwingApp.main(args)"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started learning Python... I am writing a simple program that will take
I just started learning C. What I am trying to right now is that
I just started learning PHP, and have been trying to build a website to
I am new to Scala, just started learning, so this is basic beginner question.
I just started learning C but I don't understand this part of the code.
I´ve just started learning GWT and I´m trying to implement http://gwt.google.com/samples/Showcase/Showcase.html#!CwFileUpload and but failing
I just started learning Common Lisp a few days ago, and I'm trying to
I have just started learning Scala and I'm now wondering how I could implement
Just started learning Rails (3). I am tearing my hair out trying to find
I've just started learning Scala, and the first thing I'm going to implement is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.