Reputation: 985
I have a maven project in IntelliJ IDE. I have created a package with name event.handlers
. After which I created multiple classes inside this package.
There are no classes inside event
everything is inside event.handlers
.
Now I want to create a java class inside package event
.
Is there any way from the IDE I can do that?
Currently, I am manually creating the java file inside the event
folder in my code repository.
Upvotes: 3
Views: 2806
Reputation: 4569
It might be easier to just create the class inside package AB
and Refactor > Move
to place it inside of A
.
It seems that all other answers here are workarounds anyway, so if it's just a one-off, this might be the easiest option.
However, in my case, after doing this I had to "Invalidate Caches and Restart" before IDEA updated the UI properly.
Upvotes: 0
Reputation: 2699
In the left Project structure pane, there is Settings button, in that please Uncheck, Compact Empty Middle Packages.
The settings will be like
Now you will have a tree structure, where you can right-click or (ctrl + enter/ alt + insert) on the package and create the file.
For example,
Upvotes: 10
Reputation: 5214
Try creating a Java Class
at src
folder named event.NewClass
. This will create a NewClass.java
inside src/event
.
You can create folder with the dot symbol .
at creating a Java Class
or a Package
, or Kotlin File/Class
when Type
is not File
. For example create a Package
with name com.company.example
at src
folder will automatically generate the folders recursively, src/com/company/example
, create a Java Class
with name com.company.example.AClass
will automatically generate a file AClass.java
inside the automatically generated folder tree src/com/company/example
.
Upvotes: 2