Courseiva
Java Platform Overview and PackaginghardMultiple ChoiceObjective-mapped

ModuleNotFoundException: Missing Module on Module Path in Java 17

A Java 17 application is deployed on a server. The application uses modules but one required module is missing from the module path. Which exception will be thrown at startup?

Quick Answer

The correct exception here is java.lang.module.FindException, because that is the specific exception the Java module system throws when module resolution, which runs before your application code ever executes, cannot locate a required module on the module path. ModuleNotFoundException sounds plausible because its name mirrors ClassNotFoundException, but it simply does not exist as a standard Java exception type, which is why questions like this test whether you actually know the API rather than guessing from naming conventions. The remaining distractors fail for a different reason: they are real exceptions, just not ones tied to this startup-time module resolution step. ExceptionInInitializerError is thrown later, when a class's static initializer fails, while NoClassDefFoundError and ClassNotFoundException both relate to ordinary class loading rather than to the module system verifying that every required module is present before the JVM even begins running your code. The pattern to remember is that missing-module problems surface as FindException during resolution, while missing-class problems surface as NoClassDefFoundError or ClassNotFoundException during class loading, since these are two separate phases of startup with two separate exception families. When a question describes a module missing from the module path, go straight to FindException rather than reaching for an exception name that merely sounds consistent with how Java normally names its 'not found' errors.

⚠ Common exam trap

Candidates may confuse module-level errors with class-level errors, but the actual exception for a missing module is FindException, not any of the listed options.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

ModuleNotFoundException

None of the listed exceptions are correct. When a required module is missing from the module path during startup in Java 17, the module system throws `java.lang.module.FindException`, not `ModuleNotFoundException`. `ExceptionInInitializerError` occurs during static initialization, `NoClassDefFoundError` when a class is missing at runtime, and `ClassNotFoundException` at class loading. `ModuleNotFoundException` is not a standard Java exception.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ExceptionInInitializerError

    Why it's wrong here

    ExceptionInInitializerError is thrown when a static initializer fails, not due to a missing module at startup.

  • NoClassDefFoundError

    Why it's wrong here

    NoClassDefFoundError occurs when a class that was available at compile time is missing at runtime, not during module resolution.

  • ClassNotFoundException

    Why it's wrong here

    ClassNotFoundException is thrown when an application tries to load a class by name, not for module resolution.

  • ModuleNotFoundException

    Why this is correct

    ModuleNotFoundException is not a standard Java exception; the correct exception is java.lang.module.FindException.

About these practice questions

This 1Z0-829 question is part of Courseiva's 513-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

1 more way this is tested on 1Z0-829

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. A developer receives the above error when running a modular Java application. What is the most likely cause?

medium
  • A.The module-info.java has a syntax error.
  • B.The module 'com.example.app' is not on the module path.
  • C.The JRE version is too old.
  • D.The main class is misspelled.

Why B: When a modular Java application throws an error indicating that a module cannot be found, the most common cause is that the module's JAR or directory is not present on the module path. The module path is specified using the `--module-path` option (or `-p`) when launching the application with `java --module`. If `com.example.app` is not on that path, the module system cannot resolve it, leading to a `ModuleNotFoundException` or similar error.

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This 1Z0-829 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-829 exam.