Unable to create Scala class on IntelliJ
I'm just starting to learn Scala. I have installed the Scala plugin for IntelliJ, and created a new Scala project. But when I right-click on the src folder to make a new Scala class, there is no option to do so. Am I missing something?
Solution 1:
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!
Solution 2:
I figured it out, right click on src > Mark directory as > Sources Root.
Now try again.
Solution 3:
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.
Solution 4:
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.
Now just click on the "Reload all sbt project" button.
This worked for me, I hope it will help someone.