openjdk/jdk · error

failed to get the full path of the executable: %lu

Error message

failed to get the full path of the executable: %lu

What it means

Windows counterpart of the launcher relauncher: the first GetFullPathName(argv[0], 0, NULL, NULL) call — used to query the required buffer length for the executable's full path — returned 0. The message prints GetLastError() and main returns 1, so the launcher dies before the real java is started.

Source

Thrown at src/java.base/windows/native/launcher/relauncher.c:109

    // the final quote character
    for (int i = 0; i < backslashes; i++) {
        *write_pos++ = '\\';
    }
    *write_pos++ = '"';
    *write_pos = '\0';

    return buffer;
}

int main(int argc, char* argv[]) {
    ////////////////////////////////////////////////////////////////////////////
    // Create a fully qualified path to the java executable in the same
    // directory as this file resides in.

    // Calculate path length first
    DWORD our_full_path_len = GetFullPathName(argv[0], 0, NULL, NULL);
    if (our_full_path_len == 0) {
        fprintf(stderr, "failed to get the full path of the executable: %lu\n", GetLastError());
        return 1;
    }

    char* our_full_path = malloc(our_full_path_len + 1);
    if (our_full_path == NULL) {
        perror("malloc failed");
        return 1;
    }

    if (GetFullPathName(argv[0], our_full_path_len + 1, our_full_path, NULL) == 0) {
        fprintf(stderr, "failed to get the full path of the executable: %lu\n", GetLastError());
        return 1;
    }

    char *last_slash_pos = strrchr(our_full_path, '\\');
    if (last_slash_pos == NULL) {
        fprintf(stderr, "no '\\' found in the full path of the executable\n");
        return 1;

View on GitHub (pinned to 88dfb74bbe)

Solutions

  1. Invoke java.exe with a normal, existing path (absolute path or via PATH) so argv[0] is a valid filename
  2. If launching programmatically with CreateProcess, pass a properly quoted, real application path rather than a synthetic argv[0]
  3. Check the JDK image integrity (unmodified bin\java.exe and bin\java.dll in place) and that the drive/mount holding the JDK is available
  4. Capture the Windows error code shown in the message and look it up (e.g. ERROR_INVALID_NAME, ERROR_PATH_NOT_FOUND) for the precise cause
Defensive patterns

Strategy: validation

Validate before calling

# Before launching programmatically, make sure argv[0] is a real path:
if (!PathFileExists(argv[0])) { /* fix the command line before CreateProcess */ }

Prevention

When it happens

Trigger: GetFullPathName fails on argv[0]: it can happen when argv[0] is an empty string, contains invalid characters for path resolution, or the drive/path is malformed (e.g. a detached UNC path, or a path longer than internal limits in exotic invocation contexts).

Common situations: Creating the Windows process with a bogus lpCommandLine/application name (some process wrappers, service managers, or CreateProcess calls with malformed quoting); antivirus/security software mangling argv[0]; invoking the java.exe relauncher through a subst/mapped drive that became unavailable.

Related errors


AI-assisted analysis of openjdk/jdk@88dfb74bbe (2026-08-14). Data as JSON: /api/errors/a75b5662aa0ed669. Report an issue: GitHub.