What are my options for creating a windows .exe?

I’ve downloaded both the mingw and cygwin compilers, fiddled around with them for a couple of hours, but couldn’t even compile hello world to an .exe - it looks like a case of bad documentation.

Can anybody provide the exact steps required? mingw preferred, I think, because it’s much less of a beast to download (of course, that’s the “min” part).

Do I have other options? I’ve been told it’s possible to bundle a JVM with my code - how can I do that?

Feel free to suggest any other alternatives.

I’m building with Win32, MiniGW and LWJGL. Seems ok here -

  • What build of GCJ are you using?
  • Are you trying to build anything that depends on AWT?
  • I wrote this when I got it to work: http://www.cokeandcode.com/node/422 but I wouldn’t call it step by step instructions.

Kev

I downloaded the latest stable one - but it’s not just one package to download, is it? There are several, and I’m not sure which I need, which I don’t, and which (if any) would actually hurt. If you could list exactly which packages/files I need, I’ll download all of them and post the exact errors if I still get them.

Right now, I just want HelloWorld.java to compile - which just prints to System.out. Later I can see about what classes may and may not be included.

(Is this a good time to say I’m trying to decide between Java and Blitz Basic?)

Personally, I don’t mind which you use, Blitz or Java - both good systems, both work well :slight_smile:

The package I used to get the compilation working was here: http://www.thisiscool.net/gcc40-20051104.tar.bz2

I stuck everything in jars and used:


gcj -c -fjni <jar>

to compile them into object files. Finally I linked them like any other program with:


gcj --main=<main-class-here> -Xlinker -ssubsystem -Xlinker windows *.o 

I found I had to manually link in libgcj.a to make it work - but I think that was probably me being dumb. If you’re getting errors when you try to compile - you could post them here if you like - might be able to help :slight_smile:

Kev

This ofcourse begs the question of why you need an exe at all…

Because windows intergration is less that seemless, and because users are clueless idiots?

In my case I want a painless familiar experience for the end user with a minimal download.

Kev

Because Sun still hasn’t got Web Start right, and they haven’t even got a clue at how far they are missing the mark.

You’re a mean person.

Because I’d like to make it as easy as possible for the users.

The good news:

HelloWorld.java compiled, giving me a 5.4 MB executable…

The bad news:

… which does nothing. Sigh.

Wouldnt an exe launcher suffice?

Almost every Java installer builder otu there will make one for you.

What’s that? It sounds like something that still requires a compatible VM to be installed.

… and I still can’t compile natively.

You know, I’m almost frustrated enough to write Java off as a possible development language.

Almost sounds like you think thats going to be a problem for people here. If it doesn’t work for you, thats ok, as long as your produce games - its all good like :slight_smile:

If you do want to persevere - could you let us know

a) Whether you downloaded your GCJ for win32 from GNU or from that the thisiscool post I posted above
b) What are the errors you get when you’re trying to compile your app
c) The source code you’re trying to compile (your hello world example for instance)

Incidently, have you considered http://www.excelsior-usa.com/jet.html - its another java native compiler that might work better for you if you don’t want to fight with the edge that is GCJ

Kev

PS. I’ve just discovered my HTTP POST code breaks under GCJ so its not just you :slight_smile:

It’s a bit depressing to see a newbie here facing the same crappy problems I faced years ago before I decided to cheat.
But in any case:

Build your game first. If you want to deploy it you have 6 options, all of which have advantages and disadvantages. In order of increasing hassle and pain:

1. Deploy with Webstart, assume user has a VM installed.
Complexity: trivial
Advantages: small payload
Disadvantages: generally computers don’t have a JVM installed. Overall Webstart experience is still pretty awful.

2. Deploy with native installer and maybe exe launcher, assume user has a VM installed.
Complexity: trivial
Advantages: small payload
Disadvantages: generally computers don’t have a JVM installed.

3. Deploy with native installer, download system VM if necessary in installer script.
Complexity: slightly fiddlier
Advantages: almost guaranteed to work
Disadvantages: Extra unexpected download for many users.

4. Deploy with native installer, bundle VM inside game
Complexity: slightly fiddlier
Advantages: trivial, guaranteed to work, easy to work with
Disadvantages: large payload

5. Deploy with native installer, bundle sneaky small VM inside game
Complexity: pretty fiddly
Advantages: guaranteed to work, very small payload, easy to work with
Disadvantages: Grey legal area. Ahem. Use any AWT at all and you might as well bundle the whole VM.

6. Compile natively with Jet
Complexity: pretty fiddly
Advantages: can’t use a lot of Java classes. Very high performance.
Disadvantages: Expensive. Use any AWT at all and you might as well bundle the whole VM. Difficult to work with.

7. Compile natively with GCJ
Complexity: ultrafiddly
Advantages: can’t use a lot of Java classes. Use any AWT at all and you might as well bundle the whole VM.
Disadvantages: Incredibly difficult to work out. Questionable performance. Gain versus pain ratio also questionable.

If you use ANY AWT code at all, you won’t be able to use #5, #6, or #7 to any real advantage.

None of this applies to the Mac. And forget about Linux if you want to actually make more money than the hair replacement therapy it will cost you.

Cas :slight_smile:

Yes it does. But then again your game requries that it be installed if it is a native so whats the difference?
The VM can be incldued with your gameinstall and the user need never even know it exists.

Take a look at some commerical Java games like Tribal Trouble. It installs and runs very seemlessly without being compiled.

If youa re really stuck on compiling to natvie then maybe you dont really want java.
shrug

There ARE commercial full Java compilers out there. They tend to be expensive and of limited practical use.

On windows you can silently install the VM without the user knowing, so comiling to native shouldn’t be necessary. I agree it would really be good if Sun provided an installer for java apps that included the VM. As well as WebStart there needs to be a DiskStart!.

No matter what programming language you use, you’re going to have to include some kind of code for the graphical user interface, music, loading images, etc. You could write your own, download free libraries, or just use what’s included in the SDK. Whichever way you do it, you’re going to have a large download. The only way you could ever have a small download is if you were doing a game that lacked alot of features and didn’t include any 3rd party libraries or the SDK.

So you might as well just embed the JRE or have an installer script that downloads it only if it’s needed. Install4J can do either, but it costs a bundle. There are other cheaper alternatives, but they cost money too. Embedding the JRE yourself is relatively easy and free, and I believe you can write a script with NSIS that downloads other files (such as the JRE) only if they need to be installed.

This doesn’t make any sense - just because a game will include a whole bunch of libraries means it’s ok to bundle a whole load more unnessisary ones in the form of the JRE? Size does not equal features or quality.

The biggest reason that I’d want an exe file is that the JRE can’t be installed from a CD or disk using WebStart unless the machine already has a WebStart JRE installed (http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/cdinstall.03.06.html shows how to install an app from CD when a WebStart JRE is already present).

UM two things. I thiught there was actually a way to install webstart with a pre-loaded cache.

Second, if all yo uwant is to install, there are a TON of Java installer builders.