I’m familiar with C++ but never used Java. I’ve just started learning Android development. In most of the basic tutorials I’ve gone through mentioned packages names like org.example.hello. I know they are some sort of unique identifiers but
- How should I choose these packages names? Are there any guidelines?
- Is there anything special I need to keep in mind if I’m developing a commercial application?
- How can I make separate re-usable libraries and pack them in different packages/applications?
thanks.
Package naming is largely irrelevant, except there are some major conventions. For example. the Java API is largely under
java.. The real purpose is to avoid conflict with other code.The primary impact package naming has is on visibility. Protected members, for example, are available to the same package (and subclasses), but not to code in other packages.
For example, on my phone, code seems to be primarily in
com:but some is in
org(mostly open source stuff):Some discussion on Wikipedia:
http://en.wikipedia.org/wiki/Java_package#Package_naming_conventions
As long as your company name (and app name) is in the package name, you should be fine.
Eclipse has provisions for linking multiple projects together as libraries. If you are using ant for your build process, you can do the inclusion there. There’s not a real concept of a “library” (a JAR file in J2SE) that I’m aware of. Actual JAR files (as compiled for J2SE) need to be cross-compiled to the Android format (DEX).