{"record":{"id":"a75b5662aa0ed669","repo":"openjdk/jdk","slug":"failed-to-get-the-full-path-of-the-executable-lu","errorCode":null,"errorMessage":"failed to get the full path of the executable: %lu\n","messagePattern":"failed to get the full path of the executable: %lu\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/java.base/windows/native/launcher/relauncher.c","lineNumber":109,"sourceCode":"    // the final quote character\n    for (int i = 0; i < backslashes; i++) {\n        *write_pos++ = '\\\\';\n    }\n    *write_pos++ = '\"';\n    *write_pos = '\\0';\n\n    return buffer;\n}\n\nint main(int argc, char* argv[]) {\n    ////////////////////////////////////////////////////////////////////////////\n    // Create a fully qualified path to the java executable in the same\n    // directory as this file resides in.\n\n    // Calculate path length first\n    DWORD our_full_path_len = GetFullPathName(argv[0], 0, NULL, NULL);\n    if (our_full_path_len == 0) {\n        fprintf(stderr, \"failed to get the full path of the executable: %lu\\n\", GetLastError());\n        return 1;\n    }\n\n    char* our_full_path = malloc(our_full_path_len + 1);\n    if (our_full_path == NULL) {\n        perror(\"malloc failed\");\n        return 1;\n    }\n\n    if (GetFullPathName(argv[0], our_full_path_len + 1, our_full_path, NULL) == 0) {\n        fprintf(stderr, \"failed to get the full path of the executable: %lu\\n\", GetLastError());\n        return 1;\n    }\n\n    char *last_slash_pos = strrchr(our_full_path, '\\\\');\n    if (last_slash_pos == NULL) {\n        fprintf(stderr, \"no '\\\\' found in the full path of the executable\\n\");\n        return 1;","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/openjdk/jdk/blob/88dfb74bbeefcf2b0aa11835183bcd949998fc8f/src/java.base/windows/native/launcher/relauncher.c#L91-L127","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Invoke java.exe with a normal, existing path (absolute path or via PATH) so argv[0] is a valid filename","If launching programmatically with CreateProcess, pass a properly quoted, real application path rather than a synthetic argv[0]","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","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Before launching programmatically, make sure argv[0] is a real path:\nif (!PathFileExists(argv[0])) { /* fix the command line before CreateProcess */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass a fully-quoted, existing java.exe path when using CreateProcess programmatically","Keep the JDK on stable local storage, not vanishing network mounts"],"tags":["jdk","launcher","windows","relauncher","installation"],"backgroundTag":null,"analyzedSha":"88dfb74bbeefcf2b0aa11835183bcd949998fc8f","analyzedAt":"2026-08-14T11:45:09.665Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}