How should I name a Java package?

10,260

A common naming scheme used is the following (| means or):

country| org|com.name.applicationName.subpackages

Name is either a company or your name. And after the applicationName you start all your subpackages (that is what I mean in the end) e.g. util, ui,db etc

For example if you are John Dave from England use en.jdave.smartapp.ui.core.forms. Or Marcus German From Germany: de.mgerman.smartapp.ui.core.forms etc

Share:
10,260
Macro206
Author by

Macro206

Updated on June 30, 2022

Comments

  • Macro206
    Macro206 almost 2 years

    Possible Duplicate:
    What package naming convention do you use for personal/hobby projects in Java?

    I am learning Java and have found a problem. I would need a domain name for my packages, but I don't have one. I wouldn't like to use my email address. So should I make an account on SourceForge or GitHub and use that? If so, which one is best? Or is there another, better method? Thanks

  • Jeffrey
    Jeffrey almost 12 years
    If you use that idiom, it implies that you own that domain. The OP does not own a domain.
  • Macro206
    Macro206 almost 12 years
    Could I use a GitHub domain as my domain?
  • Cratylus
    Cratylus almost 12 years
    The idea is that this is a common structure to create a package name.Use for name your company name or your personal name.For example if you are John Dave from England: en.jdave.smartapp.ui.core.forms. From Germany: de.jdave.smartapp.ui.core.formsetc Also it doesn't have to be something universally unique unless you expect to be used by major companies across the world
  • cubuspl42
    cubuspl42 almost 6 years
    "I am learning Java and have found a problem. I would need a domain name for my packages, but I don't have one"