Skip to content
Advertisement

Eclipse Java – invalid package name – Reserved words in package name

I am in the middle of an android project and was trying to create a new package in it.

JavaScript

Well, Eclipse is not letting me to create it and is showing this error:

Invalid package name. ‘new’ is not a valid Java identifier

I never knew package name has reserved words, which we cannot use. My questions are;

  1. Is this an Eclipse thing? or a Java thing? I tried a pure Java project (not Android), just to check, but there also I got the same error.
  2. What are other reserved words that is not allowed?
  3. Is there any documentation about this?

Advertisement

Answer

Yes, this is a general Java thing.

The list of reserved words can be found here. They are:

JavaScript

Documentation on the fact that reserved words can not be used in package names if found in the package naming tutorial, among other places.

The authoritative source is (as always) the Java Language Specification, specifically:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement