4KJO (four Kilobyte game JAR optimiser)

yeah, for some reason it seems to not be assigning the “input” jar which whould lead to those errors.

I cannot replicate the problem on my end which disturbs me.

Can someone else try the utiltiy on the jar oNyx supplied to see if there is something different about my local system?

It’s not working, I get errors and then it shuts down.

  1. I downloaded 4kjo and extracted it
  2. Ran “java -jar 4kjo.jar -gui”
  3. Saved the default config into “c.xml”
  4. Copied “starship.jar” into the 4kjo directory
  5. Ran “java -jar 4kjo.jar -config c.xml -output starship_final.jar starship.jar”
C:\Stuff\Download\4KJO>java -jar 4kjo.jar -gui
Cannot open configuration file default.xml, using default (hard-coded) values.

C:\Stuff\Download\4KJO>java -jar 4kjo.jar -config c.xml -output starship_final.jar starship.jar
Cannot open configuration file default.xml, using default (hard-coded) values.
Class: S HAS MAIN METHOD.

current optimiser: PROGUARD OPTIMIZER
ERROR OCCURED WHILE OPTIMISING... skipping to next permutation...
java.lang.Exception: JAR file Corrupt: missing main class or other classes
        at Process.optimize(Process.java:506)
        at Process.permutate(Process.java:692)
        at Process.run(Process.java:171)
        at FourKJO.main(FourKJO.java:57)
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)

C:\Stuff\Download\4KJO>

This is good (in a way :stuck_out_tongue: ) It can only get more stable when solving these issues.

can you send me the starship.jar (budgetanime AT hotmail DOT COM) ?

It looks like proguard is having issues. (what version of java did you compile it with? did you try compiling to the 1.4 compatible? )

I took your starship4K.jar and ran it through the optimiser. It had no errors, however the JODE optimised a little too much and the mouse buttons were not registering, but removing the JODE optimiser from the list to try, 4KJO was able to get another 47 bytes.

The settings i used if you want to repeat are attached:

Pretty impressive :slight_smile:

Sorry, I forgot to send you an unoptimized jar that caused that error. I’ll try to send you both the jar file and the xml file when work is over.

I tried to run that config, but got errors:



C:\Stuff\Download\4KJO>java -jar 4KJO.jar -config bestConfigOut.xml.txt -output S2.jar S.jar
Cannot open configuration file default.xml, using default (hard-coded) values.
java.io.IOException: File: BJWFlate.exe already exists!
        at Process.copyExecutable(Process.java:710)
        at Process.run(Process.java:64)
        at FourKJO.main(FourKJO.java:57)
Class: S HAS MAIN METHOD.
current optimiser: JOGA OPTIMIZER
ERROR OCCURED WHILE OPTIMISING... stopping...
java.io.FileNotFoundException: null\JoGaDIR\S_JOGA.jar (The system cannot find the path specified)
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(Unknown Source)
        at java.util.zip.ZipFile.<init>(Unknown Source)
        at Process.stillHasClasses(Process.java:564)
        at Process.optimize(Process.java:506)
        at Process.run(Process.java:189)
        at FourKJO.main(FourKJO.java:57)
java.io.FileNotFoundException: C:\Stuff\Download\4KJO\S.jar.BEST_OPT.jar (The system cannot find the file specified)
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(Unknown Source)
        at java.util.jar.JarFile.<init>(Unknown Source)
        at java.util.jar.JarFile.<init>(Unknown Source)
        at Process.pack200Unpack200(Process.java:482)
        at Process.run(Process.java:217)
        at FourKJO.main(FourKJO.java:57)

C:\Stuff\Download\4KJO>


jar file: http://www.stratzone.net/4k/S.jar

hmm. i ran this JAR though the 4KJO using the settings i have posted earlier and it worked fine…

based on the stack trace it seems that a File.getParent() is returning null…

i am not sure why that would be the case… could you try again but using a fully qualified file name and path to the input JAR?

i.e.

4KJO>java -jar 4KJO.jar -config bestConfigOut.xml.txt -output C:\Stuff\Download\4KJO\S2.jar C:\Stuff\Download\4KJO\S.jar

Can any one let me know what would cause the file system to not know what the parent would be?

Seems to have worked. :slight_smile:

good to hear.

That behavior of returning null is not what i would expect… i will have to see if i can get around it.

Based on some ideas formed when making this utiltiy i now have a preliminary process which seems to give approximatly 50-100 extra bytes.

This is based on embedding a pack200 compressed version of the optimised jar file (i.e. one which has been through the 4KJO optimiser) onto the end of a “launcher” class file.

This launcher class reads the embedded pack200 compressed jar, converts it into a normal JAR, adds the normal JAR into a classloader and then calls the constructor of the “main” class.

Since there is some foolery with File and ClassLoader the resulting JAR will need to be signed, or be an executable JAR.

I have attached an executable version of “Starship Invaders” which has been compressed from 4093 bytes to 4,034 bytes.

I hope with further optimisations of the launch class I can increase the gain.

if it were not for the need to sign the jar the byte saving would be much greater… :frowning:

Pretty impressive work :slight_smile: I might revisit the code and add some nice features that I had to cut out :slight_smile: thanks!

Ehem… p200 isn’t allowed.

it is not allowed on the server side, i.e. the server is not allowed to send the jar via pack200 as it is deemed unfair as many web hosts do not have a pack200 transport system inplace.

By embedding the pack200 in the jar itself, the web server does not need to have the pack200 transport system as it it the client that extracts itself, i.e. it is still vaid as part per the rules as i under stand them.

http://javaunlimited.net/contests/java4k.php

[quote]Contest Rules
Basic rules are as follows:
[…]

  • No Pack200
    […]
    [/quote]

That is true, for the server side…

http://www.java-gaming.org/forums/index.php?topic=14771.0

see the second paragraph. Pack200 is disallowed on the webhost.

see the second paragraph

That one simple outlines the reasoning. And it doesn’t matter what has been said in some thread or on irc, if there is a page with rules. “No Pack200” means no pack200. No matter how you look at it. Even some lawyer with mad law bending skills couldn’t work around that.

(Btw you aren’t the first one who had that idea ;))

The reason Pack200 is disallowed is, it “relies on server-side configurations”.

I think woogley meant to disallow the Pack200 way of distributing your file, not using the technology, if it doesn’t “rely on server-side configurations

It’s like saying “It is against the law to carry guns, because it lowers the threshold to commit murder” (sorry, Americans)

That doesn’t mean “It is against the law to carry guns” for the military.

(aaaah, don’t you love those scewed examples?)

I guess we both had different interpretations of that rule.

Can woogley or someone or someone involved in the organisation please advise?

If it is decided that embedding a pack200 compressed jar in an self executing jar is against the spirit of the rule then I am more than willing to concede.

Well, it says “no pack200”, so I guess that means no pack200 ;D