Skip to content

fix(windows): use JAVA_HOME when java is not on PATH#8656

Merged
nhumblot merged 2 commits into
dependency-check:mainfrom
mohan485:windows-java-home-fix
Jul 23, 2026
Merged

fix(windows): use JAVA_HOME when java is not on PATH#8656
nhumblot merged 2 commits into
dependency-check:mainfrom
mohan485:windows-java-home-fix

Conversation

@mohan485

Copy link
Copy Markdown
Contributor

Description of Change

Updated the Windows launcher template to use JAVA_HOME to locate the Java executable when JAVACMD is not set. If %JAVA_HOME%\bin\java.exe exists, it is used; otherwise, the launcher falls back to the default Java executable (java) on the system PATH.

This change allows the Dependency-Check CLI to run on Windows when JAVA_HOME is configured but java.exe is not present on the PATH, while preserving the existing behavior for users who set JAVACMD or rely on PATH.

Related issues

Fixes #8631
This fixes issue #8631, where the CLI fails on Windows if JAVA_HOME is configured but java.exe is not on PATH.

Have test cases been added to cover the new functionality?

This change updates the Windows launcher script only. The behavior was verified manually by testing the following scenarios:

JAVA_HOME configured and java.exe not on PATH → CLI starts successfully.
JAVACMD configured → launcher uses JAVACMD.
JAVA_HOME not configured but java.exe available on PATH → existing behavior is preserved.

@boring-cyborg boring-cyborg Bot added the cli changes to the cli label Jul 12, 2026
@mohan485 mohan485 changed the title Fix Windows CLI to use JAVA_HOME when java is not on PATH fix(windows): use JAVA_HOME when java is not on PATH Jul 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Windows CLI launcher template to locate java.exe via JAVA_HOME when JAVACMD is not set, addressing Windows environments where Java isn’t on PATH (Fixes #8631).

Changes:

  • Add a JAVA_HOME-based lookup for %JAVA_HOME%\bin\java.exe when JAVACMD is empty.
  • Preserve existing fallback behavior to the default Java executable when JAVA_HOME does not provide java.exe.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cli/src/main/conf/windowsBinTemplate.bat
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@nhumblot nhumblot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: thank you for your help!

@nhumblot
nhumblot merged commit 797a0a0 into dependency-check:main Jul 23, 2026
15 checks passed
@nhumblot nhumblot added this to the 13.0.0 milestone Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli changes to the cli

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dependency-check.bat does not use JAVA_HOME

4 participants