Cannot run main object

With the below hello world, the plugin does not recognize that this is a main class. I all compiles find however.

idea 8.1.3 and latest plugin

package com.si.reporting

object Main {
   def main(args:Array[String]) = {
     println("greeting")
   }
}

0
3 comments

It's type inference issue. Because we run just main methods, which return Unit (I think it's not right in common). By in this example println("") treated as Nothing, so runner fails.
Now I can suggest you to add explicit type:


package com.si.reporting

object Main {
   def main(args:Array[String]): Unit = {
     println("greeting")
   }
}





 

This case works well.

Best regards,
Alexander Podkhalyuzin.

0

Another way to make a function return Unit is to omit the assignment
operator '=' before the opening brace '{', as in:

object Main {
def main(args: Array[String]) {
println("greeting")
}
}

Greetings
/// Odd Möller


"Alexander Podkhalyuzin" <no_reply@jetbrains.com> wrote in message
news:33044704.132491246945538510.JavaMail.clearspace@app8.labs.intellij.net...

It's type inference issue. Because we run just main methods, which return
Unit (I think it's not right in common). By in this example println("")
treated as Nothing, so runner fails.
Now I can suggest you to add explicit type:

>

 package com.si.reporting
>
> object Main {
> def main(args:Array[String]): Unit = {
> println("greeting")
> }
> }
>
>
> ]]>

>
>

This case works well.

>

Best regards,
Alexander Podkhalyuzin.

>

---
Original message URL:
http://www.jetbrains.net/devnet/message/5241340#5241340


0

Please sign in to leave a comment.