Skip to content

Maven 4 does not start when JAVA_TOOL_OPTIONS is set and the project has .mvn/jvm.config #13405

Closed

Description

@slachiewicz

Affected version

4.0.0-rc-7 (same code on master and maven-4.0.x)

Bug description

Maven 4 does not start when the project has .mvn/jvm.config and any of JAVA_TOOL_OPTIONS, _JAVA_OPTIONS or JDK_JAVA_OPTIONS is set. Maven 3.9.16 and 3.10.0 build the same project.

$ cat .mvn/jvm.config
-Xmx512m
$ JAVA_TOOL_OPTIONS=-Dfoo=bar mvn -o validate
Picked up JAVA_TOOL_OPTIONS: -Dfoo=bar
Error: Could not find or load main class Picked
Caused by: java.lang.ClassNotFoundException: Picked

With JDK_JAVA_OPTIONS the class is NOTE:, from the JVM's NOTE: Picked up JDK_JAVA_OPTIONS line. The exit code is 1.

concat_lines in bin/mvn (line 402 on master, 208 on maven-4.0.x) has captured the output of JvmConfigParser.java with 2>&1 since #11365. The JVM that runs the parser prints its "Picked up …" notice on stderr, so the notice becomes part of the JVM options, and its first word is taken as the main class. JAVA_TOOL_OPTIONS is common on CI runners and in containers, and invoker-based integration tests set it to tune the forked JVMs.

Capturing only stdout would fix it, with stderr shown only when the parser exits non-zero. I have not checked mvn.cmd.

Activity

  1. added
    bug
    on Oct 11, 2026
  2. Yashisinghal285 commented on Oct 12, 2026

    @Yashisinghal285
    Contributor

    Hi, I'd like to work on this issue. I'll investigate the output capture in bin/mvn and look into adding a regression test for the JAVA_TOOL_OPTIONS case. Please let me know if anyone is already working on a fix. Thank you!

  3. Yashisinghal285 commented on Oct 12, 2026

    @Yashisinghal285
    Contributor

    I have investigated the issue and opened PR #13447 with the fix in bin/mvn along with a regression test. Feedback is welcome when you have a moment. Thank you!

  4. added 2 commits that reference this issue on Oct 14, 2026
    ba60498
    2dacfff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions