Courseiva
Java Platform Overview and PackagingeasyMultiple ChoiceObjective-mapped

1Z0-829 Java Platform Overview and Packaging Practice Question

A Java application packaged as a JAR file with a manifest containing `Main-Class: com.example.Main` is correctly run using `java -jar app.jar`. However, when run with `java -cp app.jar com.example.Main`, it throws a `NoClassDefFoundError` for a class `com.example.helper.Util`. What is the most likely cause?

⚠ Common exam trap

Oracle often tests the misconception that the manifest's `Class-Path` is always honored regardless of how the JAR is launched, when in fact `-cp` completely overrides it.

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

The JAR's manifest Class-Path entry is not being honored when using -cp.

When using `java -jar`, the JVM reads the manifest's `Class-Path` entry to locate dependencies. However, when using `-cp` (or `-classpath`), the manifest's `Class-Path` is ignored; the classpath is determined solely by the `-cp` argument. Since `com.example.helper.Util` is not on the explicit classpath, a `NoClassDefFoundError` occurs. This is a fundamental difference in how the JVM resolves classpaths between the two launch modes.

Answer analysis

Option-by-option breakdown

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

  • The Util class is missing from the JAR.

    Why it's wrong here

    If missing, even -jar would fail; but error only with -cp suggests manifest issue.

  • The JAR's manifest Class-Path entry is not being honored when using -cp.

    Why this is correct

    When using -cp, the Class-Path from manifest is ignored; you must explicitly include dependencies.

  • The -jar option automatically adds the JAR's dependencies to the classpath.

    Why it's wrong here

    It reads the Class-Path from manifest, but does not work with -cp.

  • The main class name is misspelled.

    Why it's wrong here

    NoClassDefFoundError indicates missing class, not wrong main.

Visual reference

Client Recursive Resolver Root DNS (13 root servers) TLD DNS (.com, .org, …) Authoritative example.com query IP addr answer

About these practice questions

One of 513 original 1Z0-829 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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.