user2248702
user2248702

Reputation: 2998

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?

Upvotes: 7

Views: 12388

Answers (3)

Greg Artisi
Greg Artisi

Reputation: 172

some words are not allowd like new, or numbers, maybe switch also.

Upvotes: 0

pranavmalhotra
pranavmalhotra

Reputation: 152

You probably had a space after the packagename.

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

Upvotes: 0

JB Nizet
JB Nizet

Reputation: 691715

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

Upvotes: 6

Related Questions