Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot create package IntelliJ IDEA

I am attempting to create a package for my project in IntelliJ IDEA. I am naming the package 'com.mydomain.switch' Switch being the project name, but as soon as I type 'switch' it shows an error.

The only thing I can think of is that 'switch' is a Java keyword, is this the case? and if so what can I do about it?

like image 328
user2248702 Avatar asked Oct 02 '22 01:10

user2248702


2 Answers

When creating a package named switch, IntelliJ IDEA displays the following error message:

Not a valid package name, it would be impossible to create a class inside

So, the message is quite clear. What you can do about it: use another name. The possibilities are infinite.

Here is the list of reserved keywords, that can't be used as identifiers: http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.9

like image 161
JB Nizet Avatar answered Oct 06 '22 01:10

JB Nizet


You probably had a space after the packagename.

Intellij will give that error if the packagename ends with a space.

like image 26
pranavmalhotra Avatar answered Oct 06 '22 00:10

pranavmalhotra