OnlyRuntimeLibraryPackages
DRAFT

Misconception:

The people who created the Java Development Kit (JDK) created packages to provide us with the Java runtime library (like java.lang, or java.util). Application developers can not create their own packages.

Incorrect

Only the creators of the JDK can create packages

Correct

Normal developers can create packages

Correction
Here is what's right.

Every developer can place any class in a package. While the Java runtime library that is part of the JDK consists of classes that are placed in packages like java.lang or java.util. However, developers can place their own classes in packages as well.

For example, the following source code, to be stored in a file OnlyRuntimeLibraryPackages.java in a subdirectory org/progmiscon/misconception/java, defines a class with the fully-qualified name org.progmiscon.misconception.OnlyRuntimeLibraryPackages:

package org.progmiscon.misconception;

public class OnlyRuntimeLibraryPackages {
  //...
}

All that is needed to put a class in a package is to put a package declaration at the top of the Java source file (e.g., package org.progmiscon.misconception;) and place the source file in a subdirectory that corresponds to the package’s name (e.g., org/progmiscon/misconception).

Value
How can you build on this misconception?

This misconception provides an opportunity to discuss the ideas of modularity, hierachical name spaces, and separate compilation.

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.