Skip to content

Commit

Permalink
* exewrap 1.6.3
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osdn.net/svnroot/exewrap/exewrap/trunk/exewrap@96 d83a06de-854e-4732-85b7-fdf7162022b6
  • Loading branch information
hirukawa_ryo committed Sep 14, 2020
1 parent 8629c39 commit 1f0493f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/exewrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int wmain(int argc, wchar_t* argv[])
L" -s \t Create Windows Service application.\r\n"
L" -A <architecture> \t Select exe-file architecture. (default %ls)\r\n"
L" -t <version> \t Set target java runtime version. (default 1.5)\r\n"
L" -l <search-flags> \t Set Java VM search location flags\r\n"
L" -l <search-flags> \t Set Java VM search location flags.\r\n"
L" -M <main-class> \t Set main-class.\r\n"
L" -L <ext-dirs> \t Set ext-dirs.\r\n"
L" -e <ext-flags> \t Set extended flags.\r\n"
Expand Down
26 changes: 20 additions & 6 deletions src/jvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,7 @@ BOOL set_application_properties(SYSTEMTIME* startup)

BOOL initialize_path(const wchar_t* relative_classpath, const wchar_t* relative_extdirs, BOOL use_server_vm, DWORD vm_search_locations)
{
wchar_t* path_env = NULL;
wchar_t* module_path = NULL;
wchar_t* buffer = NULL;
wchar_t* search = NULL;
Expand Down Expand Up @@ -920,6 +921,13 @@ BOOL initialize_path(const wchar_t* relative_classpath, const wchar_t* relative_
}
*(wcsrchr(module_path, L'\\')) = L'\0';

path_env = (wchar_t*)malloc(BUFFER_SIZE * sizeof(wchar_t));
if(path_env == NULL)
{
goto EXIT;
}
GetEnvironmentVariable(L"PATH", path_env, BUFFER_SIZE);

jvmpath[0] = L'\0';

// Find local JDK
Expand Down Expand Up @@ -1435,10 +1443,6 @@ BOOL initialize_path(const wchar_t* relative_classpath, const wchar_t* relative_

GetModuleFileName(NULL, buffer, BUFFER_SIZE);
wcscpy_s(libpath, BUFFER_SIZE, L".;");
wcscat_s(libpath, BUFFER_SIZE, jvmpath);
wcscat_s(libpath, BUFFER_SIZE, L";");
wcscat_s(libpath, BUFFER_SIZE, binpath);
wcscat_s(libpath, BUFFER_SIZE, L";");

if(relative_classpath != NULL)
{
Expand All @@ -1460,6 +1464,8 @@ BOOL initialize_path(const wchar_t* relative_classpath, const wchar_t* relative_
wcscat_s(path, BUFFER_SIZE, token);
if(is_directory(path))
{
wcscat_s(libpath, BUFFER_SIZE, path);
wcscat_s(libpath, BUFFER_SIZE, L";");
add_path_env(path);
add_dll_directory(path);
}
Expand Down Expand Up @@ -1498,6 +1504,8 @@ BOOL initialize_path(const wchar_t* relative_classpath, const wchar_t* relative_
wchar_t* dir = dirs;
while(*dir)
{
wcscat_s(libpath, BUFFER_SIZE, dir);
wcscat_s(libpath, BUFFER_SIZE, L";");
add_path_env(dir);
add_dll_directory(dir);

Expand All @@ -1509,9 +1517,11 @@ BOOL initialize_path(const wchar_t* relative_classpath, const wchar_t* relative_
}
}

if(GetEnvironmentVariable(L"PATH", buffer, BUFFER_SIZE))
// PATH環境変数の内容もjava.library.pathに含めます。
// JPKIなどのライブラリをロードするために必要になります。
if(path_env != NULL)
{
wcscat_s(libpath, BUFFER_SIZE, buffer);
wcscat_s(libpath, BUFFER_SIZE, path_env);
}

add_path_env(binpath);
Expand All @@ -1523,6 +1533,10 @@ BOOL initialize_path(const wchar_t* relative_classpath, const wchar_t* relative_
path_initialized = TRUE;

EXIT:
if(path_env != NULL)
{
free(path_env);
}
if(module_path != NULL)
{
free(module_path);
Expand Down

0 comments on commit 1f0493f

Please sign in to comment.