Well someone made it easy!
1. Download and install this bundled build of GCC/GCJ 3.3 for Windows (MingW) and SWT. Follow the instructions to put into your path it’s bin directory.
2. Create your simple HelloWorld app as HelloWorld.java:
class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello World");
return;
}
3. Navigate to that directory from a command prompt and type:
>gcj –main=HelloWorld -o HelloWorld HelloWorld.java
4. Now execute your HelloWorld.exe:
>HelloWorld
It runs! The executable is a little larger then I had hoped (3.5MB), but that beats telling users they need a JVM installed! More about it in this JavaLobby thread. I write many non-GUI utilities and this maybe just the trick for some of them. This originates with the article I linked to earlier at IBMDeveloperWorks, Create native, cross-platform GUI applications, revisited.
Apparently this sort of thing Just Works in Mac OS X, even to the point of being able to put Java application into the same bundles that native apps use. (A bundle is just a directory ending in .app with the bundle bit set.)
It’s nice when an OS platform vendor doesn’t have such an antagonistic relationship with its developers’ chosen tools.
I’m jealous.
Yeah, I just wish I had some kind of Big Awesome Project to work on so I could use all this.