user3685285
user3685285

Reputation: 6606

Scala files don't get compiled to .class files in out folder

I am using Intellij. I am trying to add a scala main class (called abc.def.ghi.MyClass) to my java project which uses gradle. The java files all get compiled to .class files in the out directory, but my scala file remains a .scala file (not sure if this is related). When I try to the main class in the scala file, I get the following error:

Error: Could not find or load main class abc.def.ghi.MyClass

In my build.gradle, I have included the scala plugin like so:

apply plugin: 'scala'

at the top of the page. What do I need to do to get this to work? The project was originally created a s a java project, and any java main classes work totally fine.

Upvotes: 0

Views: 463

Answers (1)

Mark Kegel
Mark Kegel

Reputation: 4520

According to the latest gradle docs:

All the Scala source directories can contain Scala and Java code. The Java source directories may only contain Java source code.

My guess is that you've put your scala source under src/main/java.

If you continue to run into issues, checkout this guide. It has a complete build.gradle that you should be able to get started with.

Upvotes: 1

Related Questions