7

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?

3
  • docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html Commented Apr 12, 2014 at 9:31
  • 1
    @NimChimpsky the question is not about switch keyword. it is about packagename 'com.mydomain.switch'. Commented May 22, 2021 at 12:46
  • @krishnaTelgave oh really ? I wonder why the switch package name doesn't work then ? Commented May 24, 2021 at 4:17

3 Answers 3

6

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

Sign up to request clarification or add additional context in comments.

1 Comment

Is there any convention for naming classes where the desired name is not possible?
0

You probably had a space after the packagename.

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

Comments

0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.