Package Name Case Conventions: All Lowercase
What you'll learn: You'll learn why Java package names should always be written entirely in lowercase letters.
The Convention
While Java technically allows package names to contain uppercase letters, the universal convention is to write all package names in lowercase. This is not enforced by the compiler, but it's a standard practice followed across the entire Java ecosystem.
Why All Lowercase?
This convention serves several practical purposes:
-
Avoiding name collisions: Since Java is case-sensitive,
com.mycompanyandcom.MyCompanywould be different packages. Using all lowercase eliminates confusion. -
Cross-platform compatibility: Some operating systems treat file names as case-insensitive (like Windows), which could cause problems if packages differ only by case.
-
Clear distinction from classes: Classes follow PascalCase (like
MyClass), so lowercase packages make it immediately obvious what's a package and what's a class.
Examples
// ✓ CORRECT: all lowercase
package com.mycompany.utilities;
package org.example.networking.http;
// ✗ INCORRECT: contains uppercase (works, but violates convention)
package com.MyCompany.Utilities;
package org.Example.Networking.HTTP;
Think of It as a Road Sign
Just as road signs use consistent colors and shapes to convey meaning instantly (red means stop, yellow means caution), lowercase package names signal "this is organizational structure" at a glance, while uppercase signals "this is a type definition."
Key Takeaway: Always use lowercase letters for package names—it's the universal Java convention that prevents collisions, ensures compatibility, and maintains clear distinction from class names.