问题
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 ;
回答1:
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.
回答2:
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.
回答3:
Thanks for the replies, but in the meanwhile I solved the problem:
The code line became:
import poof.textui ;
(poof is the folder where my project is)
And when compiling used:
-cp poof-support.jar:.
来源:https://stackoverflow.com/questions/27131302/java-package-with