Compile Java excutables? How? It's so confusing!

| 3 Comments

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.

3 Comments

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.

About this Entry

This page contains a single entry by Karl published on May 22, 2003 1:01 PM.

After seeing "Hurt"... was the previous entry in this blog.

Punk and churches in the Inquirer is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Monthly Archives

Powered by Movable Type 5.01