Running a scala application

Hi,

I'm trying to run a scala application with the latest version of intellij 13.1.4 with the recommanded scala plugin. 0.38.441


I have created a non-SBT scala project. In the src i create a package myApp then inside of it i create an object MyApp as follows:

package myApp

/**
* Created by maatary on 31/07/14.
*/
object MyApp extends App{

  println("hello world")

}


I want to run that. I go to run -> EditConfiguration. There I choose Application and i create an new configuration based on that. However at that point, Intellij do not accept my myApp object for the class that contain the main.

How can i do ? I just don't understand...... This should be easy.... by the the worksheet works fine. As global libray i use scala 2.11. Intellij is set to point to the folder where it is situated in my computer.

Any help here ?

11 comments
Comment actions Permalink

This problem looks important as some people have similar complains, but we can't reproduce it. If it's stability reproducible for you, it would be great to give you special build, which can collect more debug info from your installation. You can create an issue here http://youtrack.jetbrains.com/issues/SCL and we willcontinue investigation of this bug.

What about other options? I mean for example if you create SBT project, is it the same? (creating SBT project is the simplest way to start hacking Scala in IntelliJ IDEA).

Best regards,
Alexander Podkhalyuzin.

0
Comment actions Permalink

I solved the problem. It is just that during the last update, Intellij lost the Java SDK content. I mean the path was still there (i.e. same path to the my mc OSX JDK but the content was not present). I just add to reset that. I removed it and added it again. And everything worked fine.

0
Comment actions Permalink

Thank you for the information, we will use it as possible solution for such problem as well as we will try to add some diagnostic for such possible cases in future.

Best regards,
Alexander Podkhalyuzin.

0
Comment actions Permalink

I was plagued by the same problem. What I observed: running the project under JDK 1.6.0_65 and JDK 1.7.0_67 works fine, under JDK 1.8 I get the mentioned problem building a Run configuration (main class not found). I tried JDK 1.8.0_11 and JDK 1.8.0_20, no luck. Maybe Maatari was using JDK 1.8 also and got it to work by switching to JDK 1.7 or 1.6 without noticing. This is on Mac OS-X 10.9.4.

Regards,
Peter

0
Comment actions Permalink

I wasn't able to reproduce it with Java 1.8.
When plugin is looking for main method it checks, that main method is java.lang.String, so if it can't find String class it can't mark it as main method.

Best regards,
Alexander Podkhalyuzin.

0
Comment actions Permalink

I tried again from scratch using sbt. I created a new sbt project on the command line (activator new), gave it a name 'test' and imported into IDEA JDK 1.8.0_11. Creating a Run configuration for 'Application' fails. When I browse through the project and point to the main class (com.example.Hello, created by sbt), I get a "Hello is not acceptable". This is using the latest IDEA EAP 14 with Scala plugin 1.0.19 under Mac OS-X 10.9.4.

When I set the JDK to 1.6.0_65 or JDK 1.7.0_67 it works.

This is the main class created by sbt:

package com.example

object Hello {
  def main(args: Array[String]): Unit = {
    println("Hello, world!")
  }
}

Thanks and regards,
Peter

0
Comment actions Permalink

I created an issue http://youtrack.jetbrains.com/issue/SCL-7477
If I find the reason, I'll close it. So you can follow this ticket.

Best regards,
Alexander Podkhalyuzin.

0
Comment actions Permalink

Thanks for filing a ticket. Were you able to reproduce the problem or is it just my MacBook/OS-X 10.9.4?

Regards,
Peter

0
Comment actions Permalink

I asked QA to try to reproduce, and tried to do it myself, and for now it's not reproducible for us.
Ticket can attract people with similar problem, then we will probable find solution. Or at some point I'll take a look for it again without reproducible example and find a reason.

I also can try to add some diagnostic and attach to that ticket, currently I don't know what diagnostic to attach. And of course the best way is to debug IDEA for you by yourself to find a reason, for this particular case it should be really easy. Any questions or suggestions you can add directly to the ticket.

Best regards,
Alexander Podkhalyuzin.

0
Comment actions Permalink

Thanks, I will update the YouTrack ticket if I find something.

Regards,
Peter

0
Comment actions Permalink

I had this problem and ended up here.  It was because my application class was created as a "class", not an "object".  I see that Maatari Okouya did not make this mistake, but I want to leave this solution here in case anyone in future makes this mistake.

1

Please sign in to leave a comment.