Skip to content
Ameen Abozaid
Planned lessonMID-010-L02

Writing module descriptors

  • Lesson 2 of 5
  • Mid-level
On This Lesson 4 topics

This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.

In this lesson

write a module-info.java.

Planned topics

  • Place module-info.java at the source root; the module name is usually reverse-domain style.
  • requires declares a dependency; requires transitive passes it on to users.
  • exports makes a package accessible to other modules; unexported packages stay hidden even if public.
  • exports ... to limits to named modules.
  • A JAR with a descriptor on the module path is a module; unnamed or automatic modules cover legacy JARs.
Draft outline details

Demonstration

java
module com.shop.core {
    requires java.sql;
    exports com.shop.core.api;
}

Check your understanding

Can another module use a public class in a non-exported package?

Show answer

No.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.