Question about creating simple Scala program in Eclipse

View: New views
2 Messages — Rating Filter:   Alert me  

Question about creating simple Scala program in Eclipse

by ilangostl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi
I created a simple Scala (Scala 2.8) HelloWorld program in Eclipse 3.5 (Galileo) with the Scala plugin. It had the following lines in it: All this was done on my Mac OS X  Leopard

package hello
object HelloWorld{
  println("hello world");

}

I then went to Run -> Run Configurations -> Double clicked on Scala Applications and then enter hello.HelloWorld in the Main class field.

I pressed Run thereafter.

Eclipse reported: Exception in thread "main" java.lang.NoSuchMethodError: main

Then I changed the first line of the program to: object HelloWorld extends Application

I repeated the steps above.

This time I got what I wanted to see: hello world

Now I am trying to understand the guts of a Scala program.

Why do I have to say" HelloWorld extends Application

1) What is "Application" and does application come with a main method that acts as an entry point.
2) Now, just like every Java program brings in java.lang by default, what does a Scala program bring into it by default?
3) How does the Scala interpreter invoke the JVM?

Thanks in advance
ilango

Re: [scala] Questiob about creating simple Scala program in Eclipse

by Tony Sloane :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Ilango,

Your questions and many more like them can be answered by reading the
resources available at this page:

http://www.scala-lang.org/node/960

regards,
Tony

On 04/11/2009, at 12:08 PM, ilangostl wrote:

>
> Hi
> I created a simple Scala (Scala 2.8) HelloWorld program in Eclipse 3.5
> (Galileo) with the Scala plugin. It had the following lines in it:  
> All this
> was done on my Mac OS X  Leopard
>
> package hello
> object HelloWorld{
>  println("hello world");
>
> }
>
> I then went to Run -> Run Configurations -> Double clicked on Scala
> Applications and then enter hello.HelloWorld in the Main class field.
>
> I pressed Run thereafter.
>
> Eclipse reported: Exception in thread "main"  
> java.lang.NoSuchMethodError:
> main
>
> Then I changed the first line of the program to: object HelloWorld  
> extends
> Application
>
> I repeated the steps above.
>
> This time I got what I wanted to see: hello world
>
> Now I am trying to understand the guts of a Scala program.
>
> Why do I have to say" HelloWorld extends Application
>
> 1) What is "Application" and does application come with a main  
> method that
> acts as an entry point.
> 2) Now, just like every Java program brings in java.lang by default,  
> what
> does a Scala program bring into it by default?
> 3) How does the Scala interpreter invoke the JVM?
>
> Thanks in advance
> ilango
>
> --
> View this message in context: http://old.nabble.com/Questiob-about-creating-simple-Scala-program-in-Eclipse-tp26168128p26168128.html
> Sent from the Scala mailing list archive at Nabble.com.
>