Forum Stats

  • 3,782,726 Users
  • 2,254,680 Discussions
  • 7,880,148 Comments

Discussions

Creating an executable

843807
843807 Member Posts: 46,582
edited Feb 28, 2003 12:50PM in Java Desktop Applications
Hi, I want to create an executable program or launcher for the application i have built in java. I want to turn the java class files into something that a inexperienced user could execute simply. Are there tools to do this?

Many thanks.

Martin

Comments

  • 843807
    843807 Member Posts: 46,582
    I'm working with JBuilder 7 SE. In the SE edition JBuilder has a feature called "Native executable builder".

    I tried building a windows executable from a small application and it seemed to work fine. An "Executable" was built that could be run from command line and by double clicking a link from the desktop.

    But note that there's still a java runtime environment needed for the built file.

    HTH Daniel

    P.S.: Don't know if JBuilder 7 SE is still available, but when we bought it it was about EUR 500,-. Not that expensive, I think.
  • 843807
    843807 Member Posts: 46,582
    go here:

    http://forum.java.sun.com/thread.jsp?forum=54&thread=359679

    That might help :)
    :) I made it, I kniow! :)
  • 843807
    843807 Member Posts: 46,582
    Dear zzzzb,

    as Martin wrote he had the .class files already. Please be so kind and read the original posting carefully BEFORE you post something, ok?

    Thanks, Daniel
  • 843807
    843807 Member Posts: 46,582
    You can try NativeJ at http://ctech-software.hypermart.net/nativej.html.
    It should do what you need.
  • 843807
    843807 Member Posts: 46,582
    BTW:

    Has anyone tried InstallAnywhere? Seems to generate a pure Java Setup that works on any platform. But is the incredible cost for purchasing worth it?
  • DrClap
    DrClap Member Posts: 25,479
    Incredible cost? If you are looking for a free version go to this page:

    http://www.zerog.com/products_ia_07.html

    and scroll all the way to the bottom.
  • 843807
    843807 Member Posts: 46,582
    Dear Martin,

    To create an executable for java class files are easy. Just put java fileName in batch file. If you would prefer to have an exe file, then write the following codes in C.

    main()
    {
    printf("Welcome to Your application name");
    printf("Starting the application Please wait....");
    system(" Echo OFF ");
    system(" java fileName ");
    system(" cls ");
    system(" exit ");
    }

    that is all the fun. Just compile the above code and put the exe in the directory where the class file is.
  • 843807
    843807 Member Posts: 46,582
    Haijsk,

    That's a pretty nice trick. Straightforward, and simple to use. The one problem is that it opens a console window under Windows. :-( As a result, you inspired me to write this piece of code:
    #include <windows.h>
    
    #define MY_APP_NAME "MyApp"
    #define MY_APP_EXEC "javaw -jar myapp.jar"
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
    {
            STARTUPINFO startup_info;
            PROCESS_INFORMATION process_info;
    
            BOOL valid;
            int result;
    
            startup_info.cb = sizeof(startup_info);
            startup_info.lpReserved = NULL;
            startup_info.lpDesktop = NULL;
            startup_info.lpTitle = NULL;
            startup_info.dwX = 0;
            startup_info.dwY = 0;
            startup_info.dwXSize = 0;
            startup_info.dwYSize = 0;
            startup_info.dwXCountChars = 0;
            startup_info.dwYCountChars = 0;
            startup_info.dwFillAttribute = 0;
            startup_info.dwFlags = STARTF_FORCEONFEEDBACK;
            startup_info.wShowWindow = NULL;
            startup_info.cbReserved2 = 0;
            startup_info.lpReserved2 = NULL;
            startup_info.hStdInput = NULL;
            startup_info.hStdOutput = NULL;
            startup_info.hStdError = NULL;
    
    
    
            valid = CreateProcess(
                    NULL, 
                    MY_APP_EXEC, 
                    NULL, 
                    NULL, 
                    FALSE, 
                    CREATE_DEFAULT_ERROR_MODE, 
                    NULL, 
                    NULL,
                    &startup_info, 
                    &process_info 
            ); 
     
            if(!valid)
            {
                    result = MessageBox(NULL, "Failed to launch the application. Please make sure that a JVM of 1.3 or higher is installed.", MY_APP_NAME, MB_OK);
            }
    
            return 0;
    }
    Just change MY_APP_NAME and MY_APP_EXEC to meet your needs and away you go. :-)
This discussion has been closed.