Java Package with -

TJacob picture TJacob · Nov 25, 2014 · Viewed 7.1k times · Source

How do I import a package named "poof-support" .

No, I can't change the package name, I'm getting an: error '.' expected . The line giving the error is:

import poof-support.exception ;

Answer

Johny picture Johny · Nov 25, 2014

You can't have - in your package name. So you will need to change the name.

Some Package Naming Conventions from java Documentation

  • Package names are written in all lower case to avoid conflict with the names of classes or interfaces.

  • 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". In this event, the suggested convention is to add an underscore. For example:

  incorrect names                | correct names
  ---------------------------------------------------------  
  hyphenated-name.example.org    | org.example.hyphenated_name
  example.int                    | int_.example
  123name.example.com            | com.example._123name

check this link for naming conventions of package.