Tree [cdc45d] default /

Read Only access

File Date Author Commit
 examples 2013-01-24 groboclown groboclown [cdc45d] Add an example showing off parsing data and add...
 resources 2013-01-12 groboclown groboclown [1d9135] Merge with 4d58efdae0cbcba5a39fb580f423fae3c071...
 tools 2013-01-24 groboclown groboclown [cdc45d] Add an example showing off parsing data and add...
 .hgignore 2012-12-11 groboclown groboclown [a26a61] Restructure the examples, and help the build wo...
 readme.txt 2012-12-14 groboclown groboclown [cb08df] Update build to remove some bugs, and improve t...

Read Me

Java 4k Build Tools

This project contains a collection of Ant build scripts and Java tools to aid
with constructing a Java 4k game contest entry.  This allows for a repeatable
process for constructing the final file.

It provides a basic framework to compile the Java game file, and any tools used
to construct that file.

Note that a full build with kzip can run for hours as it performs an exhaustive
search to squeeze every byte out of the final pack200 gzip file.

Effort has been made to allow this project to work on a range of platforms.
However, it has only been tested on Windows and Linux.  One of the tools
supported by this framework (DeflOpt) is Windows-only, so extra effort must be
made to allow it to run on Linux (described below).

How To Use

Setup Environment

Before you get started, make sure you have have Ant (
and a Java JDK installed on your computer.

The framework can take advantage of some additional tools:
    * yguard:
        A free-to-use Java library that can shrink class files.  The license
        prohibits it from being distributed with this package.
    * jshrink:
        Another class file shrinker.  This one has a trial license version,
        but if it's used with this framework, then you'll have to manually
        configure and run the tool during the build process.  Registered
        versions of the tool will run without the need for user input.
    * 7-Zip
        A compression tool that has some descent results.  Download the
        version appropriate for your platform (it's a native application).
        It has versions for Windows and Linux.
    * kzip
        A compression tool that creates incredibly tight zip files.  It
        has Linux and Windows native clients.
    * DeflOpt
        Tries additional compression techniques to squeeze even more bytes out
        of zip files.  It has a Windows-only client.

The java4k build framework also ships with several versions of proguard, but
it is setup to only run with one version.  Different versions of proguard
create different minimized class files, so you may want to experiment with
these to find the right one for your project.

DeflOpt is Windows only, but you can setup your system to run it on Linux.
This requires creating a shell script that will run DeflOpt through Wine.
Additional steps may be required in the script to ensure that all paths are
reachable through Wine.

Create Build Structure

Your game project can be located anywhere on your computer, but it will need to
be layed out in this format.  Replace "gamedir" with the name of your project.

    - The build file that references the java4k framework files, and possibly
        extends it.
    - Properties file that defines some project specific settings for the
    - This directory contains the game source file.  It can contain multiple
        source files, but only one will actually be used (see below).
        This directory can be overridden (see
    - If you have some Java source files that you use for generating or
        modifying the base source files, the sources are placed here.  They
        will be compiled as part of the build process.
    - Additional resources used by the game.  These can be input files used by
        tools to generate or augment the source file, or the HTML page
        used to display the applet.

You should create a "" file in your game directory, or its
parent, to define your local setup.

The build will generate the directories "gamedir\work" and "gamedir\exports".

Configuring Your Build

At a minimum, you will need to define in your, the
property "" to the name of the fully-qualified class name.
This should be just a single letter (you don't want to waste bytes on the
class name, or on a package).

In addition to this, you can override the properties defined in
"resources/" by setting them in your file.
Note that the "src" property should be set per project, and not globally,
as this is used when generating source files.

The "examples" directory contains some examples and templates to get you
started building a Java 4k game.

Running The Build

Run "ant" in your build to construct the final jar file.  This can take a
very long time, especially when kzip is included (the build exhaustively
uses kzip to squeeze out that last byte).

If you want to just quickly compile and test the application, then you
can run "ant test".

How It Works