4KJO (four Kilobyte game JAR optimiser)

My poorly made and non-robust utility is now at a reasonably stable level that people other than myself can probably use it :slight_smile:

This Utility attempts to perform different combinations of java byte code optimisers and different permutations of settings for kzip and BWJFlate to attempt to shrink the total size of an input JAR.

I have experimented on most of the entries thus far and they all can be compressed more by the utility.

for example:

Squarius has a 100 byte saving compressing to 3,943 bytes
l4krits has a 244 byte saving compressing to 3,783 bytes
Goop has a 142 byte saving compressing to 3940 bytes

Note: all these tests were performed using the default settings. with testing the other settings I am sure more compression would be able to be achieved.

Note 2: This utiltiy only works on windows due the use of kzip.exe and bwjflate.exe

usage:

java -jar 4KJO

will give you the command line options

java -jar 4KJO -gui

will open up a settings gui. I recommend using this to read the help file!

I do not have a webpage so the file is located at:

http://www.filehosting.cc/file/15913/4KJO-zip.html <---- OLD VERSION

see http://www.java-gaming.org/forums/index.php?topic=15497.msg124708#msg124708 for new version.

I am hoping that this utility will allow my entry to squeeze into the 4096 byte limit. Hopefully it will allow others the same!

Sweet, thanks. =D

Cool.

Great! Lots of thanks.

Do you want to give it a try with mine? I tried it and got a ton of errors and then it didn’t write the final file.

http://unlimited.woogley.net/hosted/vector.jar

All I did was ProGuard then 7zip.

I had the same errors when i tried your jar.

I recompiled your class and then tried again and it worked without a hitch. It shaved 170 bytes off your jar. (see attached file)

What version of Java did you use to compile the class in? It may not be java 6 compatible…

When i recompiled the class I was using java 1.5.04

Wow. That’s great. Thanks.

I am using JDK v1.5.0_09-b03.

Next time I will try your program before I try my stuff. That may have been the problem.

no problems :slight_smile:

Nice tool. Takes a while to go through all the “permutations”.

I do it manually though, I got JShrink which is a superb tool.

My way is the following:

  1. Shrink with JShrink
  2. Run ProGuard (check “overload agressively”, in obfuscation tab)
  3. Run JoGa
  4. Repeat step 2. and/or 3. as needed, I only had to do it once
  5. Compress contents with bjwflate.exe
  6. All done.

For my game, that did it. I ran the 4KJO tool for like 30 minutes, but it did not find any smaller compression method :slight_smile:

Of course this depends on the the code, might not work for others.

Yep, that is basically what I was doing before… manually trying all the different permutations. This utility simply auto mates it.

using the -saveOutputConfig switch it will save the best settings so that in subsequent runs you can simply add the

I will see if the evaluation version of JShrink will be able to be used in this tool. It may give better results :slight_smile:

edit:

From the JShrink website:

[quote]Note: the evaluation version of Jshrink does not include the command line or script interface used for automating obfuscation builds.
[/quote]
hmm this could make it difficult :stuck_out_tongue: but I will attempt to get it to work!

Bombed with:

[...]
PROGUARD OPTIMIZER->JODE OPTIMIZER->JARG OPTIMIZER->JOGA OPTIMIZER->
current optimiser: JOGA OPTIMIZER
java.lang.NullPointerException
        at JoGaOptimizer.cleanUp(JoGaOptimizer.java:53)
        at Process.permutate(Process.java:697)
        at Process.run(Process.java:171)
        at FourKJO.main(FourKJO.java:57)

(defaults… first run)

Jar file:
http://kaioa.com/k/fuze.jar

hmm, it would seem that the JoGa optimiser had errors silently (due to the verbosity level) and so when it tried to delete temporary files, they did not exist… I will see what i can do.

Umm… can you confirm that It gives the same error? I run the utiltiy on the jar file you provided and there was no error.

It compressed to 4044 bytes using the default configuration.

Perhaps you accidentally interacted with the JoGa GUI?

Yes, it still gives me that error. However, the point at which that happens appears to be random (takes anything from a few seconds to some minutes).

And I didn’t interact with the GUI at all. No keystrokes, no button presses and the mouse cursor stayed on the very same pixel all the time.

ok that is odd.

can you run the utility in verbose mode and pipe it into a file and then give me the output?

http://phpfi.com/183971

Then it bombed.

i am surprised… there should be alot of output on the err stream as JoGa complains alot :slight_smile:

hmm there is no stack trace or error message…

Ye… I only used >foo.txt, which only redirects stdout.

With this line stderr gets redirected to stdout (which gets redirected to some file):
java -jar 4KJO.jar -verbosity 2 fuze.jar>foo.txt 2>&1

http://phpfi.com/183980

hmm… it looks like JoGa did have an error and so it tried to clean up, but since it’s working directroy does not exist it generated another exception. I now am null checking on the clean up. replace the JOGAOptimizer.class in the 4KJO.jar with the one attached to this post.

I also suggest cleaning up any left over files, or perhaps make a new folder which contains the jar files and try it again.

Seems to not crash anymore. However, there are exceptions like:

java.io.FileNotFoundException: null\JoGaDIR\fuze_JOGA.jar

Which looks sorta weird.