Intellij doesnt show package option when I right click, I was trying to create new package on my project. I am adding the screenshot. Is there anybody know the solution? enter image description here
Asked
Active
Viewed 4,511 times
3
-
4Did you try to mark your `src` directory as `Source Root`? Right click on `src` folder -> `Mark Directory As` -> `Source Root`. After that try to right click on `src` directory and create a package – Svirin Sep 23 '20 at 14:20
2 Answers
4
Make sure that
- the module of the Java type
- the directory where you are trying to create a package or a Java/Kotlin class is marked as a source root type.

Andrey
- 15,144
- 25
- 91
- 187
1
The question already answered, as per the following thread there is very little difference between directories and packages in java parlance.
Marking a directory as the source root means, it contains all the necessary code which will be deployed and will be required to run the application.
In my personal experience I could not find a way to create classes when the directories were just directories, but marking them as source root and tells IntellJ Idea that the source code is here so it can highlight them and actually look for errors and support us in our development of application.

Prajval Singh
- 501
- 3
- 9