java program launcher

H

Hiker Hauk

Hi there,

I want to know how to write a java program launcher for Windows.

It's a .exe file to laucher a java program. Just like the one Azureus
use.

Basically, it equals command "java classname", but when looking at the
process tree, you'll see the difference.

I think it's easy to implement for people who're familiar with Win32
programming.

Could someone tell me how to do it or send me a sample program.

Thanks in advance.
 
M

Madroadie

Here is the basic app Launcher. The rest is up to you

DWORD LaunchApp(LPCTSTR szCmdLine, LPCTSTR szWorkingDir, bool bWait)
{
DWORD dwRetVal, dwCreationFlags;
STARTUPINFO sInfo;
PROCESS_INFORMATION pInfo;

dwCreationFlags = CREATE_NO_WINDOW;

ZeroMemory( &sInfo,sizeof( STARTUPINFO ) );
sInfo.cb = sizeof( STARTUPINFO );

BOOL bRet = ::CreateProcess( NULL,
(LPTSTR)(LPCTSTR)szCmdLine,
NULL,
NULL,
FALSE,
dwCreationFlags,
NULL,
szWorkingDir,
&sInfo,
&pInfo );

if (bWait)
{
WaitForSingleObject( (HANDLE)pInfo.hProcess, INFINITE );
GetExitCodeProcess( (HANDLE)pInfo.hProcess, &dwRetVal );
}
else
dwRetVal = 0;


return dwRetVal;
}
 
R

Red Orchid

Message-ID: said:
I want to know how to write a java program launcher for Windows.

Maybe .. it is as like.

<code>
(This is not tested)

int APIENTRY _tWinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow) {

STARTUPINFO si;
memset(&si, 0, sizeof(si));
si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;

PROCESS_INFORMATION pi = {0};
BOOL b = CreateProcess (
NULL,
"javaw.exe -jar -your option your file.jar",
NULL,
NULL,
FALSE,
NORMAL_PRIORITY_CLASS,
NULL,
NULL,
&si,
&pi );

if (!b) {

return -1;
}
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
return 0;
}
</code>
 
T

Thomas Kellerer

Hiker Hauk wrote on 19.02.2006 11:12:
Hi there,

I want to know how to write a java program launcher for Windows.

It's a .exe file to laucher a java program. Just like the one Azureus
use.

Basically, it equals command "java classname", but when looking at the
process tree, you'll see the difference.

I think it's easy to implement for people who're familiar with Win32
programming.

Could someone tell me how to do it or send me a sample program.

The JDK sources do include the sources for the java.exe launcher which is
exactly what you want.

Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top