Reputation: 67340
Here's what I'm seeing:
Normally I can choose "New Java Class" but for some reason I'm not getting this option. I created this project by opening an empty directory and building it out from there. I've seen this question, but that answer didn't help me. Here's my module settings:
Even if I open my pom.xml directly as a project, it still has this problem. How do I fix this?
Upvotes: 2
Views: 4176
Reputation: 1012
This worked for me :
So basically had to mark some inner folder as Source project and alter mark parent project again as Source project.. Hacky way but this worked for me.
Upvotes: 3
Reputation: 41
This happened when I was trying to add classes to a generated package using xjc plugin.
Intellij allows to add classes only to packages which are correctly names and have the "source root" status.
Can be fixed as-> right click on the directory where you're not able to add classes:
Mark sources root refer image for clarity
Upvotes: 0
Reputation: 31
The directory or one of the parent directories must be marked as Source Root (In this case, it appears in blue).
If this is not the case, right click your root source directory -> Mark As -> Source Root.
Upvotes: 3
Reputation: 67340
For some reason, intellij didn't recognize my directories as packages. If I created something directly from the java directory, it would give me the correct options. I fixed this by deleting everything under java/ and recreating it. This may be an intellij bug.
Upvotes: 1