Compiling a Java game into an executable

Started by Overkill, June 04, 2006, 23:34:16

Previous topic - Next topic

Overkill

Yes, yes, I know, some people prefer .jar files or having their Java game's source compiled on the user's side, and whatnot.

However, I'd much prefer the ability to compile to an exe, even if it requires the JRE. This is because I want people who don't have java knowledge to be able to run my game without too much strain, as this is the convenient way to attract people to my project, and it helps my artists/musicians who have no java background. If there is any free, competent compile-to-exe software, please share.

Thank you!

Matzon

there are some apps that can embed an JRE - however you can compile directly to an exe using GCJ:
http://www.cokeandcode.com/node/422

Overkill

However, there is a problem. Portions of my game require AWT, and it seems GCJ cannot support them. ;_;

EDIT: Hm, JSmooth seems capable for what I want to do. I think I'll stick with that, unless I find some obstructing aspect of the utility later.

Fool Running

You also might take a look at Launch4j. Some people say that it makes it look more professional. :D
http://lwjgl.org/forum/viewtopic.php?t=1374
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

Overkill

Ergh, well I thought I got it working, but I was wrong. I can't seem to properly export jars from Eclipse, since if I change the folder, it suddenly won't find the main class or its dependencies. Anyone else have this problem? Is it because the external libraries, or is Eclipse just lame like that?

Anyone know any okayish alternatives to compact a jar that also requires other jar files?

Fool Running

When you run the jar you need to point the VM to the other jars (with the classpath) and to the native libraries (with the -Djava.library.path=).
You should be able to set that up in JSmooth and Launch4j.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

bobjob

yoyo ummm new at this forum stuff, tryn 2 help, hope this makes sense,
currently i use exe file as batch file, running the command promt info in a c app, then compiling to exe, only prob is u can only run in windows (not even sure about vista) i use dev C++ to compile:
#include <windows.h>

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)

{
    // dont use both following lines Just 1. both do the same thing but system is better for debigging

    // system("Java -cp .\\jar\\lwjgl.jar;.\\jar\\lwjgl_devil.jar; -Djava.library.path=.\\native\\win32 ClientBatch & pause");
    //recommended for debugging notice the pause statement after the '&'


    ShellExecute(NULL,"open","Javaw","-cp .\\jar\\lwjgl.jar;.\\jar\\lwjgl_devil.jar; -Djava.library.path=.\\native\\win32 ClientBatch",NULL,SW_MAXIMIZE);
    
}

shellexecute is nicer, doesnt open any windows as long as u run javaw so looks professional. Hope that helps. i gotta say im impressed with the way tribal trouble runs through a link, packaging a version of the JVM that definetely works with the lwjgl version it uses, download is big but i assume less buggy. on my site i have a windows version of my java apps in exe. Oh and if u dont understand how 2 make ur own custom icon ill try take u through the process message me if u want, but its a step process would take a while 2 write all the steps