Why can't I create new Java classes in my Kotlin project?

Answered

I created my project using File -> New Project. I selected the Java option and as additional libraries I selected Kotlin/JVM.

After that, the project was created. I then selected the src/ directory and I created a new package inside that folder. If I want to create a new Java file inside the package, I can't. I can only create Kotlin files. However, if I click on the actual src/ folder, I am able to create Java files. If I try to move the Java file created inside src/ to the package, it isn't possible. Why? How am I able to mix Kotlin and Java files effectively?

0
3 comments

Works here:

Can you provide screenshots/screencast showing your steps and result so that I could see the project structure in project tool window? Please also specify your IDE version. Thanks.

0

Hello,

thank you for your answer. Actually, I've tried it today, and it worked. I found out why it didn't work. I used numbers at the beginning of the package name and IntelliJ interpreted it as a folder because it wasn't a valid package name, I guess. Anyway, it works now. :)

0

Thanks for the information. There is a related usability request for an enhancement to make it more clear:

IDEA-130684 warn when creating java package with invalid name.

0

Please sign in to leave a comment.