Point IntelliJ to installed Scala - scala

I'm new to Scala and IntelliJ.
I have already installed Scala on my Ubuntu PC:
printdoc#print$ scala
Welcome to Scala version 2.11.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_181).
Type in expressions to have them evaluated.
Type :help for more information.
scala>
Then, I install IntelliJ. I know that we need install Scala plugin to use Scala with IntelliJ. But I wonder if it will be duplicated because I already have Scala in my computer?
If so, how can I point the Scala location for IntelliJ, so that the IDE can re-use scala, instead of download a new one.
Which is a better practice, between installing Scala plugin and reusing installed Scala?
The same question for sbt with IntelliJ.

When not using sbt with IntelliJ, you can manually choose to use the Scala jars installed on your system, but I recommend letting IntelliJ handle it. That makes it easier to select or upgrade the Scala SDK used with your project. The files may be duplicated, but that is an insignificant amount of storage.
But to answer your question, to use an installed Scala library:
open Project structure menu / Project Settings / Modules
click the +
select Library...
select New Library / Scala SDK
To use a specific version, select it if available, or choose Download. OR click Browse and navigate to your scala installation and choose the relevant jars.

Related

Intellij does not open Scala files

I'm using IntelliJ (version 13.0) and Scala (2.9.1).
I created a Test project but Intellij does not open/display the scala files in the editor window. It displays the files only when I select the option 'Mark as Plain text' from the context menu of the scala file.
You need to install a separate plugin for Scala support: Scala plugin. This is also available directly from within IntelliJ IDEA using Preferences -> Plugins -> Jetbrains Plugins
More details about IDEA's Scala support are given here: The Most Intelligent IDE for Scala Development
Next, you need to add the Scala SDK to IntelliJ IDEA, again using the Project Structure -> SDKs. Finally add the Scala Facet to your module using Project Structure -> Facets.
A step-by-step check-list is given here: Getting Started with IntelliJ IDEA Scala Plugin. It's a bit out-of-date, but still covers all the steps.

IntelliJ 404 scala lang

Ok, I need some help in setting up a Scala project with IntelliJ, I have download and installed the project successfully, but i have had issues when it comes to installing the Scala compiler itself, WHen i go to configure a new Scalaa project and choose to set the Scala home, I choose the download Scala option and i get the following error "downloading failed, connection failed with error 404: http://www.scala.lang.org/downloads.distrib/files/scala2.10.0+RC2.tgz" i have tried downloading the things, such as primefaces and jSF through intelij, and they all work fine, any suggestions?
Download Scala manually and just select proper directory in new project window.
http://www.scala-lang.org/download/
You should be using SBT to define and build your project. Among other things, it handles retrieving the Scala compiler and libraries. IDEA is similarly self-contained as far as its Scala plug-in's internal Scala compiler is concerned. By using SBT and IDEA (see below for connecting the two), the only thing not covered is a Scala REPL for use outside of either SBT or IDEA. If you're using a Mac, Homebrew includes a Scala formula. Because SBT retrieves the Scala compiler and libraries for the version of Scala you specified, everything is self-contained.
By far the best way to build and maintain IDEA project definitions for Scala projects is with the sbt-idea plug-in for SBT. Once you install that plug-in, which is trivial, you simply use the gen-idea SBT task it provides. When your dependencies change, you run gen-idea again to update the project.

Why can't scala-ide refresh change in java classes in scala editor?

I found a problem using scala-ide 2.1.0 m2.
I'm developing a java/ scala mixed project. When I add a method in java class and call it in scala. Scala Ide will report an error that the method doesn't exists. I tried to refresh the project but I got no luck. I have to restart Eclipse(3.7 indigo) to let scala IDE load the updated java class.
Is there any way to let scala IDE recognize java changes without restarting eclipse?
Cleaning the project works for me in same situation.
Scala IDE is improving quite a lot lately. I had few problems mixing java and scala in one Eclipse project (generated by SBT, but not very relevant for this question) using the latest Eclipse IDE (Juno) and the latest version of Scala IDE.
I'd advise to download the latest version of Eclipse and and install the latest version of the Scala IDE.

In Eclipse, can I choose the version of Scala for my project?

Currently I'm using Scala IDE, and the version of Scala it's using for my project is 2.9.2. Preferably I'd like to choose 2.8.1, and am not sure how to select a version of the Scala Library.
Is there any way to change the version?
Thanks!
http://scala-ide.org/docs/user/gettingstarted.html
"The list of URLs of the different update sites are available in the download area. The release ones are in the current section. Scala IDE is linked to specific version of Scala, so you have to decide which one you are going to use:
release-29 provides support for projects using Scala 2.9.x (2.9.0-1 or 2.9.1). This is the current version of Scala. Pick this one if you are unsure.
release-28 provides support for projects using Scala 2.8.x (2.8.1 or 2.8.2)."
So you have to install release-28 Scala IDE to compile your Scala project with version 2.8.1 .
The release site can be found here:
http://scala-ide.org/download/current.html

Access the Eclipse Scala compiler from the terminal

I'm just starting out with Scala (trying to setup Eclipse, Lift and SBT on Mac Lion) and I'm not sure if I need the scala compiler through homebrew or can I just use the built in Eclipse Scala compiler through Eclipse and (if I also need to) through the Terminal.
If that's a good idea, how do I run it through the terminal ?
You won't be able to access the Eclipse-IDE scala compiler through terminal, so if you want terminal access, you should install a standalone scala interpreter separately.
While you don't technically need terminal access since Eclipse will compile everything for you and you can run the interpreter through Eclipse (Window -> Show View -> Scala Interpreter), I like to have the option, so I always have a separate installation of the same version of the compiler that Eclipse uses.
Instead if installing scala, I normally have a blank sbt project, and start the scala REPL by doing
sbt console
This allows me to easily change scala versions and if I add dependencies to the project, they will be added to the console classpath.