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

new is a java keyword. Use some other word instead of it.


See docs here:

http://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html

In some cases, the internet domain name may not be a valid package name. This can occur if the domain name contains a hyphen or other special character, if the package name begins with a digit or other character that is illegal to use as the beginning of a Java name, or if the package name contains a reserved Java keyword, such as "int".


Yes, this is a general Java thing.

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

abstract  continue    for         new         switch
assert    default     goto        package     synchronized
boolean   do          if          private     this
break     double      implements  protected   throw
byte      else        import      public      throws
case      enum        instanceof  return      transient
catch     extends     int         short       try
char      final       interface   static      void
class     finally     long        strictfp    volatile
const     float       native      super       while

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:

  • § 3.9 Keywords and
  • § 3.8 Identifiers

    An identifier cannot have the same spelling (Unicode character sequence) as a keyword (§3.9), boolean literal (§3.10.3), or the null literal (§3.10.7), or a compile-time error occurs.