Cannot run a Scala program in IntelliJ - scala

So I made a project in Scala -> Activator. I am trying to run it but I cannot even select it, it has a main function. When I press the alt+shift+F10 nothing happens at all.
The icon for the main.scala file also has some red thing in the bottom right corner, which I'm unsure what that means.
Also if I edit the file there is no star at the filename, like if it was unchanged.

Answering rather than deleting this question. I solved the problem by creating a Maven project or by using sbt, it will not run right out of the gate like Java (coming from a Java background).

Related

IntelliJ IDEA 2022.2.3 Scala Worksheet not working

New to scala and I am doing this course https://www.coursera.org/learn/effective-scala
I am following the installation instructions, have installed Scala, latest JDK and IntelliJ on my PC. I installed the Scala plugin as well.
I have downloaded the empty project from the course and imported it into Intellij and have opened the worksheet which has just some basic lines inside. When i try to evaluate the project, the right side shows nothing, but the green tick it had before turns to an exclamation mark, so something must be wrong...
I can't click the exclamation mark or hover over it, no errors to be seen anywhere apart from the visual, see the screenshot below:
As you can see top right there is a red circle with an exclamation mark in it.
Note that when I run the Scala REPL, that works fine, as you can see below with the latest version
I ran into a similar issue while trying something out in Intellij IDEA 2022.2.4 (Ultimate Edition) on macOS Ventura.
Do the following to fix it:
Click the little spanner icon (Show worksheet settings).
On the first tab in the dialogue box (Settings for <sheet name>),
=> Check Interactive Mode
=> Change Run Type to Plain
=> Click OK.
[Optional] If you don't see the evaluation happening after those settings, click the Play button (Evaluate worksheet) on the worksheet. This should only be for the first time (automatic evaluation in subsequent changes to the worksheet content.
See the image below for the settings described above:

Intellij Scala Type Info stopped working

Scala's Type Info from the View menu and by pressing ctrl-shift-p has just stopped working. I press and nothing appears ever. I upgraded the IDE and the plugin but it doesn't make a difference. Any help on how to fix it would be appreciated.
Try File > Project Structure > Global Libraries and make sure you have at least one scala-sdk present.
In the same screen, select Modules and check the Dependencies tab and make sure your scala-sdk is present (it's usually toward the top of the list).

Show which class/traits/object are incorrect in IntelliJ's Project window

How do I have IntelliJ's Project window show me which class/traits/object are incorrect in terms of compiling - before compiling? This was shown in NetBeans back in the day.
I am talking about this window:
After all, IntelliJ is able to show me the little green tick in the upper right corner:
It doesn't work for Scala as for Java. You can see that file Issue1.java won't compile.
But you can use Make Project feature that will Compile all modified and dependent files in a project by hitting Ctrl+F9.

Why is IntelliJ highlighting errors in one project, but not another?

I'm using IntelliJ 13 and the Scala plugin. In one project if I make an obvious type error I get a visual indication, like this:
But I just started a new project and a similar thing is not highlighted, even after I compile.
I'm giving a presentation on some Scala code and I'd like it if the type errors highlighted like in the first one, but I have no idea where the setting is.
One reason could be that the level of highlighting is set to a lower setting. Check your lower right corner for a button which adjusts this setting with a slider. It looks like (at least to me) a policeman face :)
Another thing is that you might not have declared what additional languages you're using besides the primary one. You can configure this in the project settings.
Also if you are using a tool to build a project (like Maven for example) try rebuilding or reimporting your project.
edit: One last thing. Make sure IDEA isn'currently reindexing or running some background tasks, this really messes up code correction.

Eclipse 3.4.1 - how to view compiler output in Console while building a project

I have what appears to be a very annoying problem. When compiling a project in Eclipse, I see no Console that shows the invocation of the Java compiler and the build results (as in NetBeans).
If I, for instance, import an existing project into Eclipse and invoke Project->Build Project, is there a view that will show me results of the compilation? While I know that my project contains a number of files that have errors, invoking Build Project shows no visual result/progress of the compilation. It does not show the list of errors so that I can quickly jump to them.
I'm aware that there is a "Problems" view, which shows a list of problems (and not just compiler errors) in all projects and not the particular project that I am working with, which makes it very inconvenient to locate and jump to source of the problem.
You can configure the problem view to show only problems in the current project:
Click on the small triangle at the far right of the view.
In the popup menu, select "Configure Contents..."
Select each item in the "Configurations" list and click on "Scope: On any element in the same project"
If you want to see the compiler working, you need open the "Progress" view.
Since Eclipse JDT provides its own built-in Java compiler, you generally do not see the invocation of Java Compiler.
The built-in Java compiler is tightly integrated with Eclipse and JDT, and provides the source indexing that enables powerful IDE features such as refactoring and quick fix.
Plus, it enables incremental build in background after each file modification, hence no visible "java" invocation.
You can replace/complete the java compiler with a javac` call of your own:
For instance, Using Alcatel-Lucent nmake with Eclipse JDT does precisely that, and uses a configuration launcher (which you can instruct to show a console):
You will need to add that special builder in the "builder" section of your project.
Do not forget you can create many "Problem view", and set one of them to show only problems for your current project.
Select: "on any element in same project"
Goto Windows->Show View->Console
or
Alt+Shift+Q,C
Console appears in tab with Problem view
Your question contains a couple of assumptions that you might want to re-think.
It does not show the list of errors so that I can quickly jump to them.
Errors are flagged in the edit window while you are editing. You can fix them on the spot, without having to "jump" anywhere.
If you drop an entire source file into your project, you may not be in an edit window on that file. (And, of course, that's not standard Eclipse usage.) The simplest way I know do deal with that is simply to "Refresh" the project and look in the Package Explorer view to see whether there are any errors detected (which will happen immediately if you "refresh" a file into a source folder). Double-click on any files which show an error icon and look at the right-hand side of the edit window to see exactly where the errors are.
I'm aware that there is a "Problems" view, which shows a list of problems (and not just compiler errors) in all projects and not the particular project that I am working with...
Unless you are using multiple projects, with inter-project dependencies, I find it useful to close all but the current project on which I'm working. Then the "Problems" view is specific to the current context.
Finally, I'd recommend looking at the Mylin "getting started" page for other hints on how Eclipse can help you focus on the current task.