Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run a Scala project as a Scala application by default in Eclipse IDE?

I am a novice to the Eclipse IDE and the question is how can I run a Scala project as a Scala application by default? When I run the project by hitting the ⌘R key, it always asks how to run it, as a Scala or Java application. Is there a way to skip this and always run it as Scala by default?

I guess it's somehow related to the launch configuration, but when I try to make a new launch configuration for the project, it doesn't give me the option of Scala: only Java applet and Java application are shown as choices.

I appreciate your help in advance!

like image 421
K J Avatar asked Jun 03 '12 17:06

K J


People also ask

How do I run a Scala application in Eclipse?

Right-click in the editor that contains your Scala source code with the main method, choose Run As / Scala Application.

How do I open a Scala project in Eclipse?

To import the Scala IDE in your workspace simply click on File > Import. The Eclipse Import dialog will open. There, select General > Existing Projects into Workspace and click Next. A new dialog will open.

How to create a Scala project in Eclipse?

Install Eclipse plugin for Scala Open Eclipse Marketplace ( Help >> Eclipse Marketplace) and search for “scala ide”. Now install the Scala IDE. Alternatively, you can download Eclipse for Scala. iii. Create a New Spark Scala Project To create a new Spark Scala project, click on File >> New >> Other iv. Create New Package

How to get the main class name of a Scala application?

Double click on Scala Application from Run Configurations window Type the Object Name in the Main Class: (for eg: if HelloWorld.scala is the object having main method, give it as HelloWorld) Show activity on this post. Make sure the project is registered as a Scala project, not a Java project or any other kind of project.

How to run a Scala project in IntelliJ IDEA?

1 Create or import a Scala project as you would normally create or import any other project in IntelliJ IDEA. 2 Open your application in the editor. 3 Press Shift+F10 to execute the application. Alternatively, in the left gutter of the editor, click the icon and select Run 'name'.

How do I use sbt to compile a Scala project?

You want to use SBT to compile and run a Scala project, and package the project as a JAR file. Create a directory layout to match what SBT expects, then run sbt compile to compile your project, sbt run to run your project, and sbt package to package your project as a JAR file.


Video Answer


1 Answers

Window > Preferences > General > Keys

Scroll down and select Run Scala Application

Edit the Binding to ⌘R or whatever you want.

This changes the binding for your whole workspace, so it doesn't distinguish between Java and Scala applications. It would be nice if the runner had a box you could tick to choose the default, but this is a decent workaround.

like image 185
Luigi Plinge Avatar answered Sep 29 '22 18:09

Luigi Plinge