Trying to create a scala based project on intelli and all the tutorials i see ask me to click on new project and select scala on the left and sbt on the right.
I cannot see a scala option on the left.
I have already installed the scala plugin. Also restarted intellij several times.
The project wizard in recent IntelliJ versions looks and works a bit differently than before. You need to select the primary language for the new project and then specify additional details such as SDK and build tool versions.
In your case, you need to choose Scala in the "Language" selector, then sbt in the "Build system" section (the options in the section change based on the language chosen):
For more information, consult the documentation.
Related
I am using IntelliJ and would like to create a new Scala Package. In all of the instructions that I find online I see that I am supposed to select "Package" from the "New" menu. However, my "New" menu does not include "Package" as an option.
How can I add "Package" to this list or otherwise add a package to my Scala application?
Also as a side note, I am developing Scala applications and as such I would like for primarily Scala related templates to appear in this list as opposed to the menagerie or irrelevant templates that currently presents itself. How can I edit the list of templates that appears in this menu?
I solved this problem by taking the following steps:
Making sure to install both the Scala and SBT plugins. (I was missing the SBT plugin)
Copying all the source files (*.scala) into a temporary location
Deleting the project.
Creating a new project with the same structure and copying the source files into their proper location.
Now "Package" appears in the menu (and full syntax hilighting now works, which was the reason why I wanted to fix this in the first place). Note that simply installing the SBT plugin (step 1) was not sufficient in fix this problem.
Maybe it was a bug.
How do I access Scala docs in IntelliJ? The other answers in SO are for earlier versions. I added the scala doc jar file, but still I am unable to link scala docs with IntelliJ.
I do get the Quick Documentation as shown:
But I want the complete doc as here
Also, clicking on the Actor hyperlink shows me this code, but not the API doc. There are the download and Attach sources link and I dont understand what they are.
What do you mean by "link scala docs"? You can get documentation for a symbol (class, method) by pressing Ctrl-Q (or menu View > Quick Documentation). This seems to work at least with sbt based projects, even if in Project Structure > Project Settings > Libraries > SBT: org.scala-lang:scala-library:2.12.1:jar there is only classes and sources, and no explicit pointer to javadocs (I guess IntelliJ might extract them directly from the sources).
Also, are you using the latest version of IntelliIJ and the Scala plugin? For me, if I create a global Scala SDK (which you don't actually need when you use sbt build projects), IntelliJ by default does not have javadocs checked, but sources, and again I think it will extract the documentation from the sources. This is how it looks here with IntelliJ IDEA 2016.3.1 and Scala plugin 2016.3.5:
I added this:
to make it work. From the +, choose Scala SDK, select the version that matches your project and then add it to the module of your choice.
Wanted to start using intellij idea for my scala project and stumbled upon this link - http://theyougen.blogspot.in/2010/01/how-to-setup-maven-scala-project-with.html
Followed the steps, created a new Scala Project (without sbt), Create a new Scala Class, and copied the HelloWorld code from Scala tutorial - http://www.scala-lang.org/old/node/166.html
Went to Build > Make Project and got following error -
No compiler library set for module.
Went to File > Project Structure. On the left side, clicked on facets, and noticed that Under Compiler Compiler Library was set to none. And there is no other option available in the drop down.
How to solve this?
PS: Googled a lot, could not find any clue on how to fix this.
If on MAC
Download scala from http://www.scala-lang.org/download/
Extract it to some-location/scala
In Intellij Idea go to File, Project Structure and select Global Libraries.
Click on + button
Select Java
Give the path to some-location/scala/lib
Click ok
Apply and OK.
Go to File, Project Structure, facets. You will see a new Scala library in drop-down.
I created a project using the typical play new, and then I used play idea to generate the .iml file. When I imported the .iml file into Intellij IDEA, I could not figure out how to get the compiler library to recognize. Below are some screenshots:
Please help!
This is a slight weirdness with the Scala settings in IntelliJ. Currently the only way to register a scala distribution is to create a new project.
Steps:
File > New Project > Create project from scratch
Leave all settings as default. Project name can be anything.
On the "Please select the desired technologies" page, choose Scala. Some GUI elements will appear that allow you to tell IntelliJ how to find your scala compiler and library. Make sure to set the "Level" options to "global".
Click Finish. Close the dummy project that you created, and go back to your real project. The Scala compiler that you registered should now be in the list on your project settings page.
A variation that worked for me: drop the Scala facet and run 'Add framework support...' again.
File / Project Structure / Facets
Click Scala facet then minus to remove Scala facet from your module. Click OK.
Right click your project/module, 'Add Framework Support...', choose Scala.
Enter the path to your Scala compiler and library.
I also ran into this problem, but the workaround as described by Chris B did not work for me, since in my case "Scala" was missing on the "Please select the desired technologies" page.
In my case the problem appeared to be an incompatible Scala plugin. After I reinstalled the Scala plugin it worked fine.
I am new to intellij idea and I decided to shift because I found the scala plugin on eclipse to be annoyingly buggy.
But, intellij idea, which I have heard to be very good, looks difficult to use.
I looked through the getting started with scala plugin page but couldn't find documentation specific to the latest version of lightweight ide of intellij idea 11 for scala.
I have created a project and made a hello world object in scala but I am not able to run it.
On trying to run it, it shows the scala interpreter (type in expressions to get them evaluated).
I don't exactly understand what changes to make in the project structure to be able to run scala code. As of now, i added the jsdk to point to my $JAVA_HOME and the scala library is also added. The scala plugin is also working in that syntax highlighting etc is fine.
The intellij idea user interface is also not very friendly and I don't get how to run the code. What modules am I supposed to add? Also, does compiled scala code run with jvm?
I'll be grateful to anyone who helps out.. I have been putting off writing scala code because I am not able to find THE IDE.
EDIT: Thanks for all the help! I am now able to run a basic scala program. I am trying to add external jars. What is the equivalent of doing Project right click-> Configure Build Path -> adding external jar files in eclipse? I tried adding "dependencies " under modules tab in project structure. It's adding the jar files but somehow the classes in the jar files are not still recognised.
With the Scala plugin installed either
A. Create a new project and select the Scala facet in the creation phase. It will create the Scala library lib and Scala compiler lib and setup the facet for you
B. If you already have a project. Go to Project Structure -> Modules and right click the module and go Add facet and add a Scala facet. Now you need to add scala-library.jar as a library of the module and go into the Scala facet and point it to a library containing scala-compiler.jar
Some more information
this is what your module should look like under project settings
select the Scala facet and this is what you should see (Library name for the compiler is unimportant as long as it says (version xxx) next to the library name
these are the jar files in my scala-compiler lib
and these are the jar files in my scala-library lib
With everything setup like that you should be able to right click -> new Scala class (Select object from the dropdown) in a source directory and add
def main(args:Array[String]) {
println("Hello world")
}
then right click on the class and select Run Classnam.main() and IntelliJ will setup a run configuration for you.
Edit: I can see someone posted somewhat the same I want to say here. I hope this can give a few more in-depths hints, so I will post it anyway :-)
If you would like to run Scala native in IntelliJ (I shifted to IntelliJ and still can't get my hands down) you need to make sure a few things are in order. Most of this happens under File -> Project Structure which requires you to create a project (when you get a hang of it, it is much more logical than Eclipse -- and Netbeans for that matter). I am also assuming you have selected a jdk, but this can also be done in the Project Structure.
Now, to Scala:
Make sure you have the Scala plugin. Visit the Settings (File -> Settings; can also be found at the start-up screen) and locate 'Plugins' (for me it's nr. 8 from the bottom). Under "Browse Repositories" you should be able to search for "scala", find and install a plugin.
1 A. If no plugins pops up you are probably using a version of intellij where scala is not (yet) supported. If that happens you can go to the homepage for the plugin and download the nightly build.
Import Scala as a library in File -> Project Structure -> Global Libraries. Click the plus sign, select Java (Scala is a Java-lib), browse to your scala-dir (which can be downloaded here: http://plugins.intellij.net/plugin/?id=1347) and select the lib directory. Press ok and you should see the library popping up on the list.
Make sure the facet (Scala framework) is in place. Goto File -> Project Structure -> Facets. Click on the plus-sign and find Scala. A sublink should appear (if not double-click the Scala link). Clicking the sublink make sure you have selected a compiler before continuing. This should be provided by the modules selected before. I normally use FSC (Fast Scala Compiler) but it's probably a good idea to test the basic settings before experimenting.
Make sure the Scala Module is in place. In Project Structure -> Modules click on the module you want to compile in scala and click the plus icon above and select Scala. Again be sure to select a compiler library.
If you want to, setup configurations for the compiler under the facet
Use sbt with sbt-idea plugin to generate idea project files for complex projects.
Or
For simple projects.
Add scala nature to the project, and you can right click and run any file extending App.
A good walk-through on how to set up a Scala project in Intellij is located here:
http://sonyarouje.com/2011/03/18/running-scala-in-intellij-idea-10/