java program launcher

Discussion in 'Java' started by Hiker Hauk, Feb 19, 2006.

  1. Hiker Hauk

    Hiker Hauk Guest

    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.
    Hiker Hauk, Feb 19, 2006
    #1
    1. Advertising

  2. Hiker Hauk

    Roedy Green Guest

    Roedy Green, Feb 19, 2006
    #2
    1. Advertising

  3. Hiker Hauk

    Madroadie Guest

    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;
    }


    Hiker Hauk wrote:
    > 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.
    Madroadie, Feb 19, 2006
    #3
  4. Hiker Hauk

    Guest

    , Feb 19, 2006
    #4
  5. Hiker Hauk

    Red Orchid Guest

    "Hiker Hauk" <> wrote or quoted in
    Message-ID: <>:

    >
    > 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>
    Red Orchid, Feb 19, 2006
    #5
  6. 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
    Thomas Kellerer, Feb 19, 2006
    #6
  7. Hiker Hauk

    Hiker Hauk Guest

    Thank you all. Merci beaucoup!
    Hiker Hauk, Feb 20, 2006
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Telicalbook
    Replies:
    3
    Views:
    4,797
    Federico
    Feb 1, 2005
  2. Ant launcher

    , Jul 15, 2005, in forum: Java
    Replies:
    0
    Views:
    530
  3. Paul J. Lucas

    Writing a Windows JVM launcher program

    Paul J. Lucas, Nov 16, 2005, in forum: Java
    Replies:
    12
    Views:
    2,249
    Paul J. Lucas
    Nov 21, 2005
  4. Larry Barowski

    OS X launcher internals: dock icon

    Larry Barowski, Jan 20, 2006, in forum: Java
    Replies:
    0
    Views:
    432
    Larry Barowski
    Jan 20, 2006
  5. Peng Yu

    Install gnu Java application launcher

    Peng Yu, Aug 31, 2009, in forum: Javascript
    Replies:
    3
    Views:
    107
    Thomas 'PointedEars' Lahn
    Sep 1, 2009
Loading...

Share This Page