IntelliJ doesn't show 'Class' under right-click New: how to fix it
Codemia Knowledge Hub ·
IntelliJ IDEA only offers New > 'Class' in directories it recognizes as part of a source root. If the option is missing, the folder is usually not marked as a source root, is marked as excluded, or the project has no valid JDK. Less often, a file type association or stale caches are to blame.
The folder is not marked as a source root
This is the most common cause. If the directory is not identified as part of a source root, the 'Class' option does not appear.
- Go to
File>Project Structure>Modules. - Check that your folders are marked correctly. Usually
srcfolders are marked asSources.
In a standard layout, src/main/java must be marked as Sources for the IDE to offer class operations:
The folder is marked as excluded
- Right-click the folder.
- If
Mark Directory asshowsExcluded, change it toSources Root.
No JDK is configured
Without an appropriate JDK, Java operations such as adding classes may not be available.
- Open
File>Project Structure. - Under
Project, set the Project SDK to a valid JDK.
Wrong file type association
IntelliJ may associate files or directories with a type that excludes Java operations.
- Go to
File>Settings(orIntelliJ IDEA>Preferenceson macOS). - Open
Editor>File Types. - Make sure the file type you are working with is not assigned to an unexpected type.
Stale caches and indexes
If indexing did not run properly, it can interfere with context menu options. Rebuild the indexes by invalidating caches:
- Go to
File>Invalidate Caches / Restart. - Choose
Invalidate and Restart.
To look for other configuration problems, open IntelliJ's internal log with Help > Show Log in Explorer.
Causes and fixes
| Issue | Cause | Solution |
| Missing 'Class' option | Unmarked source root | Mark correct directories as Sources Root |
| Unrecognized Files | Incorrect file type association | Reconfigure file types under File Types |
| Java Options Missing | No JDK linked | Assign a JDK in Project Structure |
| Menu Options Missing | Folder marked as excluded | Unmark folder as Excluded |
| Miscellaneous Errors | Caches and Indexes not updated | Invalidate caches and restart IDEA |
Related reading
- IntelliJ does not terminate Spring Boot applications build with gradle
- IntelliJ Errorjava error release version 5 not supported
- intellij idea - Error java invalid source release 1.9
- Intellij IDEA complains cannot resolve spring boot properties but they work fine
- Intellij IDEA Java classes not auto compiling on save
- intellij incorrectly saying no beans of type found for autowired repository
- Intellij IDEA, format all code in a project
- IntelliJ IDEA generating serialVersionUID

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseData Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.