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!
Right-click in the editor that contains your Scala source code with the main method, choose Run As / Scala Application.
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.
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
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.
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'.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With