Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Package with -

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;
like image 346
TJacob Avatar asked Nov 25 '14 15:11

TJacob


2 Answers

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.

like image 179
Johny Avatar answered Nov 12 '22 07:11

Johny


You will have to change its name, since it's illegal to use a dash in a package name. The recommendation is to use an underscore instead.

like image 38
JB Nizet Avatar answered Nov 12 '22 06:11

JB Nizet