Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to create Scala class on IntelliJ

People also ask

How do I create a Scala class in IntelliJ?

On the Project pane on the left, right-click src and select New => Scala class. If you don't see Scala class, right-click on HelloWorld and click on Add Framework Support…, select Scala and proceed. If you see Error: library is not specified, you can either click download button, or select the library path manually.

How do I enable Scala in IntelliJ?

To install Scala plugin, press Ctrl+Alt+S , open the Plugins page, browse repositories to locate the Scala plugin, click Install and restart IntelliJ IDEA. Now you can successfully check out from VCS, create, or import Scala projects.


Right click on your project, "Add Framework support" and choose Scala framework, then by right click on the packages you can create Scala Class.

After this, right click on src > Mark directory as > Sources Root.

Doing both of these should fix your problem!


I figured it out, right click on src > Mark directory as > Sources Root.

Now try again.


I just had this issue, also. It turned out that IntelliJ hadn't marked my src/main/scala folder as a "source" folder.

To do this: Project Structure -> Modules -> right click folder and Mark as "Source" (blue)

Similarly the src/main/test folder wasn't marked as a test folder. I was able to add scala classes after those folders were appropriately marked.


I had the same problem when I created my first Scala project and I was able to solve it in a simpler way. Click on the "Search everywhere" button and type "sbt", or click directly on the "sbt" button located on the right near the edge of the screen.

sbt button

Now just click on the "Reload all sbt project" button.

reload all sbt project button

This worked for me, I hope it will help someone.


Right Click on the SrcScala folder :)

Animation of right-clicking "Scala"


I had this problem everytime I created a new project with spaces in the name. eg "Hell Wev". Using "HellWev" or similar as a project name seems to work fine