How's webstart treating the professionals out there?

Started by elias4444, January 11, 2005, 19:08:28

Previous topic - Next topic

elias4444

I posted something similar to this a while back on the javagaming forums. I've come a long way now with all of this stuff, but I'm hitting a similar roadblock. LWJGL works great with java webstart, and webstart seems to be a slick way to go for packaging software and having people download and run it. I have a few issues however that I can't seem to get around, and was wondering how the professionals out there (anyone who's officially released a game) are handling it:

1) Webstart expects that the application is stored somewhere on the internet. So, you obviously have to have a dedicated website to distribute the game. Most web-hosting services however limit the total amount of bandwidth per month. If people are always downloading your application (except, of course, after they have it cached on their machine), how do you stay within your limit? Or plan accordingly?

2) A lot of people I've spoken with don't like the idea of relying on whether a distributor (or their website) is going to stay around or not in order to reinstall their purchased product.  Is there a way to package your game up (still using webstart perhaps?) for a complete download? Which brings the 3rd issue...

3) How do you package up your application for CD distribution? I've found a few applications out there (like bootstrap), but they only cater to the windows crowd. Should you recompile everything via gcj or something? (Is that even possible though?).  Even just for windows, is there a preference for a compiled executable that launches java? A method of installation? I tried batch and script files, but they were quite messy and unprofessional looking.

Any help would be appreciated. This has been the biggest roadblock I've hit thus far when it comes to making my games in Java.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

princec

1) Plan ahead. I'm nowhere near my b/w limits.

2) Create a downloadable version too! Look at Alien Flux and Dudester to discover a naughty way to do it. If you want to be kind to Sun, put the entire JRE in.

3) No idea.

Cas :)

elias4444

What did you use to build your "SuperDudester.exe" file? Did you just code it up in C or C++ yourself?

Also, how did you know what files to include from the jre? Especially since I can't find the java.exe anywhere?!?!? How did you do that?
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

elias4444

Yours even gets it's own process name under the task manager (as opposed to "java.exe")?!?! Please, I must know how you did it.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

elias

Our (win32) installer is doing the following steps:
1. Installs an entire (private) JRE 1.5. Didn't bother detecting an already available JRE.
2. Unpack game as packaged for web start some temporary place
3. Use javaws -silent -import to bootstrap the web start cache with your game. The available web start command line options are described here:

http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/javaws.html

4. Create shortcuts to javaws <your-jnlp-file>

It seems to work ok, and the good thing is that it still uses web start for updates, so you won't have two entirely different distribution methods. We use NSIS to create the installer, and if you'd like an exaemple script file for it, tell me and I'll mail it to you.

I'm currently working on a similar installer for linux using the lokigames installer. Unfortunately a bug in SUN's 1.4.2 and 1.5 jres makes web start useless for newer linux distros. The fix is complete, but it'll not be released before 1.5.0_02 which is not out yet. Alternatively, you can use the blackdown jre, where the web start bug fix is already out, but blackdown doesn't have any 1.5 jres yet, which means that you can't use the -import option. Oh well.

Mac OS X support is hardest, since there is no 1.5 at all, and there probably won't be in the nearest future. So we're not sure how to handle that yet. A straightforward solution would be a tiny mac application/shortcut for your jnlp file which would in turn fetch your game from the 'net, but that breaks the self-contained installer paradigm.

- elias

princec

AlienFlux.exe is just a tiny C program that uses JNI to invoke the JVM, pass it a few arguments and invoke main() on xap.Game. That's all it does! Basically the same as java.exe but all the params are hardcoded.

Cas :)

elias4444

For those of us who are C deficient, is there someplace with sample code that we can go to?
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

princec

Grumble grumble have to do everything myself grumble
/*
 * Super Elvis launcher
 */

#include "launcher.h"

static JNIEnv *env;
static jobject jobj = 0;
static JavaVM *vm;

/*
 * Display an error message
 */
void messageBox(char * message) {
	MessageBox(NULL, message, APP_TITLE, MB_OK);
}

typedef jint (APIENTRY * CreateJavaVMPROC) (JavaVM **pvm, void **penv, void *args);


/*
 * Invoke our embedded JVM
 */
int WINAPI WinMain(      
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow
) {


    jint res;
	jclass cls;    
    jmethodID mid;
    jobjectArray args;
    JavaVMInitArgs vm_args;
    JavaVMOption options[4];

	options[0].optionString = "-Djava.class.path=patch.jar;superdudester.jar;gamecommerce.jar;spgl.jar;jogg-0.0.5.jar;jorbis-0.0.12.jar;lwjgl.jar";
	options[1].optionString = "-Xmx48m";
	options[2].optionString = "-Xms48m";
	options[3].optionString = "-Dworkdir=.";

	HMODULE jvmdll = LoadLibrary("bin\\client\\jvm.dll");
	if (jvmdll == NULL) {
		messageBox("Failed to load Java dll.");
	}

    vm_args.version = JNI_VERSION_1_2;
    vm_args.options = options;
    vm_args.nOptions = 4;
    vm_args.ignoreUnrecognized = TRUE;

	
	CreateJavaVMPROC CreateJavaVM = (CreateJavaVMPROC) GetProcAddress(jvmdll, "JNI_CreateJavaVM");

    res = CreateJavaVM(&vm, (void **)&env, &vm_args);

    if (res < 0) {
		messageBox("Failed to create Java virtual machine.");
        return 0;
    }

    // Get the main class
    cls = env->FindClass(MAIN_CLASS);

    if (cls == 0) {
        messageBox("Failed to find the main class.");
        return 0;
    }

    // Get the method ID for the class's main(String[]) function. 
    mid = env->GetStaticMethodID(cls, "main", "([Ljava/lang/String;)V");

    if (mid == 0) {
        messageBox("Failed to find the main method.");
        return 0;
    }

    // If there are arguments, create an ObjectArray sized to contain the
    // argument list, and then scan the list, inserting each argument into
    // the ObjectArray.
	/*
    if(dwALen > 0){
        args = (*env)->NewObjectArray(env, dwALen,
                        (*env)->FindClass(env, "java/lang/String"), NULL);
        if (args == 0) {
            messageBox("Out of memory!");
            return;
        }
        for(i=0; i<dwALen; i++){
            jstr = (*env)->NewStringUTF(env, lpszAppArgs[i]);
            if (jstr == 0) {
                 AddToMessageLog(TEXT("Out of Memory!"));
                return;
            }
            (*env)->SetObjectArrayElement(env, args, i, jstr); 
        }

    }
	*/

    // Otherwise, create an empty array. This is needed to avoid
    // creating an overloaded main that takes no arguments in the Java
    // app, and then getting a different method ID to the no-argument
    // main() method in this invoker code.
 //   else{
        args = env->NewObjectArray(0,
                        env->FindClass("java/lang/String"), NULL);
 //   }


    // Run the main class...
    env->CallStaticVoidMethod(cls, mid, args);

	return 1;

}


Cas :)

elias4444

Thanks Cas. If I haven't said it lately, you're great! I sure appreciate all the help over the last month or so that I've been learning all this stuff.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

blah

Quote from: "elias4444"
1) Webstart expects that the application is stored somewhere on the internet. So, you obviously have to have a dedicated website to distribute the game. Most web-hosting services however limit the total amount of bandwidth per month.

That's one of the reasons for JGF's existence: I would love to see all games ever released in pure java uploaded to JGF as a matter of course.

At the very least, JGF should be a backup distribution site for your game.

Although the new site isn't live yet, wait a week then look inside the preview site:

http://javagamesfactory.org

...and look for the submit-game links.

Quote
2) A lot of people I've spoken with don't like the idea of relying on whether a distributor (or their website) is going to stay around or not in order to reinstall their purchased product.

Major issue. Please find the webstart RFE on sun's site that says (in much politer words) "we need you idiots to add a basic "export" feature to webstart manager!".

Of course, JGF again helps a little by being a mirror for whatever other site you are using to dist your product.

mac

A Tool to package is JSmooth on Windows.
Exe Files can be made bundeld with JRE, ANT support, JVM properties + Application properties settable

Stay Tuned,
Jens
he Network is the Music
www.mac-systems.de