I am a beginner in Scala. I installed Scala IDE in eclipse and now I want to run my application programme. It never shows \"run as Scala application\", instead it shows \"run
Just a pointer .. I had faced same difficulty . Being experienced from JAVA , instead of creating a Spark object I was creating spark class that why I was not getting this option .
Hope my experience helps .
Download from this link Scala IDE
Restart Eclipse, create Scala Project, then create Scala Object and type this.
package greeter
object Hello {
def main(args:Array[String]) {
println("Hello, World")
}
}
Run as Scala Application
I had issues with the Scala IDE for Eclipse running Scala applications that extend Application, but running objects with a proper main method, i.e. def main(args:Array[String]) {/*...*/}
always works fine for me.
If you want to run the whole project it should have a "main class", in any of your Scala objects you should be defining:
def main(args:Array[String]) { <some nice code here> }
From there it should be "calling" the rest of your objects to do whatever the whole project does and in the "Class Main" column you should specify the fully qualified name of your object. For instance, if you defined the main in a class called "Start" in the package "starter", in the "Class Main" field you should state "starter.Start".
But on the other hand if you only want to run a Scala object it should extend App, if it doesn't extend App, Scala IDE won't add the "Run as Scala Application...":
package greeter
object Hello extends App {
println("Hello, World!")
}
Following are the steps that I took to successfully run scala(Ubuntu) on eclipse:
1. Download Scala IDE
2. After installation, create a maven project.
3. right click on the project, go to configure and "Add Scala Nature"
4. In the .pom I provided the following dependencies:
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-core -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.12</artifactId>
<version>2.4.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-sql -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.12</artifactId>
<version>2.4.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-graphx -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-graphx_2.12</artifactId>
<version>2.4.1</version>
</dependency>
Hope this helps!!!
Right click your project and check the "Scala Compiler" settings. Check the "Project Specific" checkbox and try checking if you can run your Scala object (which should extend App).