This is honestly a tiny problem but it's keeping me from proceeding with my small Java practice app.
I'm currently practicing making an API call in Java. I was trying to create a simple class file called "Film". However, when I try to create it as a class-file, Intelli-J keeps telling me that it is unable to create a class-file. I'm trying to set this file up in a folder called "models". All of these class files are going to be utilized as part of an app that performs API calls.
Is there some naming convention I haven't followed? I've been Googling but haven't really found anything.
Press ⌘1 (macOS), or Alt+1 (Windows/Linux), to open the Project Window and then use ⌘N (macOS), or Alt+Insert (Windows/Linux), to generate a new file.
To create a new Java class or type, follow these steps: In the Project window, right-click a Java file or folder, and select New > Java Class. Alternatively, select a Java file or folder in the Project window, or click in a Java file in the Code Editor. Then select File > New > Java Class.
In the Project tool window ( Alt+1 ), right-click the node in which you want to create a new class and select New | Java Class. Alternatively, select the node, press Alt+Insert , and select Java Class.
More directly, based on what @Vishal Jumani touched on, you need to tell IntelliJ what directories are 'source' or 'test' directories.
A directory structure you can use as an example, but you can use whatever you wish.
Right click on the directory you wish to mark as 'root' --> find 'Mark Directory As' --> Select 'Sources Root'
Now you should be able to add java classes in the directory without IntelliJ interrupting you!
This would usually be because of the way your project is setup. It may not be setup correctly to indicate where your source code is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With