Indiespot compression not working

Thank you StephR! It’s good to have this info available.
I don’t think the repack stage is required though, unless you want to sign the file. It does add a few extra bytes after all!
So my build is now;

javac -target 1.5 A.java

jar cvfM A.normal.jar A.class

java -jar jarg.jar A.normal.jar

java -jar proguard.jar -injars A.normal_s.jar -outjars A.proguard.jar -libraryjars rt.jar -keep public class A -optimizationpasses 9 -overloadaggressively

pack200 --effort=9 --strip-debug --no-keep-file-order -O --no-gzip A.proguard.pack A.proguard.jar

kzip /b96 /y A.proguard.kz.pack A.proguard.pack

java Zip2Gzip A.proguard.kz.pack A.proguard.kz.pack.gz

A.class (12059) goes down to A.proguard.kz.pack.gz (3961)
I’d only tinker with /b96 if it was very close to 4096. I haven’t yet found a case where it wasn’t optimal for 4K.
I fiddled with JoGa but didn’t get any reliable savings.

Ehhh it’s my first time to play with things, SimonH’s procedure seems easy but how to put that kz.pack.gz into applet? it’s not executable is it?

  • SimonH, thank you for your interest and your own help. I have to do some more tests with jarg. I think I tried it along with JoGa, and maybe this one messed with jarg’s result. Also, concerning the repack stage, by missing it, I remember my program didn’t work in the end, but maybe the problem was not related to repacking. I wish I had more time to do more tests. I will certainly do so in the coming days, to see if I get better compressing results with jarg and without repacking.

  • ReBirth, here is the code to put the kz.pack.gz file into an applet :

<applet code="a.class" archive="a.progrd.kz.pack.gz" width="your width" height="your height"><param name="java_arguments" value="-Djnlp.packEnabled=true" /></applet>

It seems it doesn’t work locally, unlike a no pack200 applet, but it would be normal. You have to try it on a server.

You can use pjt33’s test server with the applet tag;

<applet
    code=A
    archive=A.proguard.kz
    width=800
    height=600>
    <param name="java_arguments" value="-Djnlp.packEnabled=true"/>
</applet>

Which works OK.
Generally though I just unpack200 the A.proguard.kz.pack.gz file and test the resulting jar - it’s a bit less effort!

I’m having a lot of trouble getting pjt33’s test server to work. I’m using this applet tag:

<applet code="a" archive="a.jar" width="800" height="600" border="1">
  <param name="java_arguments" value="-Djnlp.packEnabled=true" />
  Sorry, Java seems to be turned off or not supported in your browser.
</applet>

When I try to load the page with the applet on it, I get the following output from the server:

Sat Dec 10 17:17:49 CET 2011 [/127.0.0.1] 200 (3966 bytes) for /a.jar.pack.gz
Sat Dec 10 17:17:49 CET 2011 [/127.0.0.1] 200 (3966 bytes) for /a.jar.pack.gz
Sat Dec 10 17:17:50 CET 2011 [/127.0.0.1] 200 (3966 bytes) for /a.jar
Sat Dec 10 17:17:50 CET 2011 [/127.0.0.1] 200 (3966 bytes) for /a.jar.pack.gz
Sat Dec 10 17:17:50 CET 2011 [/127.0.0.1] 200 (3966 bytes) for /a.jar
Sat Dec 10 17:17:50 CET 2011 [/127.0.0.1] 404 (9 bytes) for /a.class
Sat Dec 10 17:17:50 CET 2011 [/127.0.0.1] 404 (9 bytes) for /a.class

And a

java.lang.ClassNotFoundException: a

in the browser (Chrome). It looks like it successfully finds a.jar.pack.gz, but then wanders off and looks for the class a in /a.class instead.

Any suggestions on what might be wrong?

Try the applet tag without the archive having either a .jar or .pack.gz extension (see my example above) as the server automatically adds it.

Sadly not: the error is unchanged.

However, I just tried it with Cave4k’s cave.pack.gz, and that does work, so clearly the error is with my jar file. :frowning: The compression script I’m using (based off yours) goes like this:

cp ../src/a.java .

javac -target 1.5 a.java

jar cvfM a.normal.jar a.class

java -jar ~/Downloads/proguard4.6/lib/proguard.jar -injars a.normal.jar -outjars a.proguard.jar -libraryjars /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar -keep public class a -optimizationpasses 9 -overloadaggressively

pack200 --effort=9 --strip-debug --no-keep-file-order -O --no-gzip a.pack a.proguard.jar

kzip -b96 -y a.pack.gz a.pack

ls -la a.pack.gz

Maybe I made some mistake there? Thank you for all your help!

Ah, figured it out now! I wasn’t actually turning the kzip into a gzip. My updated shown-to-work approach is:

cp ../src/a.java .

javac -target 1.5 a.java

jar cvfM a.normal.jar a.class

java -jar ~/Downloads/proguard4.6/lib/proguard.jar -injars a.normal.jar -outjars a.proguard.jar -libraryjars /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar -keep public class a -optimizationpasses 9 -overloadaggressively

pack200 --effort=9 --strip-debug --no-keep-file-order -O --no-gzip a.pack a.proguard.jar

kzip -b96 -y a.kz.pack a.pack

java Zip2Gzip a.kz.pack a.kz.pack.gz

ls -la a.kz.pack.gz

Guys, please help! For me the script is not working. Here is what I’m doing:


javac -target 1.5 a.java

jar cvfM a.normal.jar a.class

java -jar jarg.jar a.normal.jar

java -jar proguard.jar -injars a.normal_s.jar -outjars a.proguard.jar -libraryjars /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar -keep public class a -optimizationpasses 9 -overloadaggressively

pack200 --effort=9 --strip-debug --no-keep-file-order -O --no-gzip a.proguard.pack a.proguard.jar

wine kzip /b96 /y a.proguard.kz.pack a.proguard.pack

java Zip2Gzip a.proguard.kz.pack a.proguard.kz.pack.gz

And my applet html file:



<applet code="a.class" archive="a.proguard.kz.pack.gz" width="600" height="600">
<param name="java_arguments" value="-Djnlp.packEnabled=true" />
</applet>


When trying to run it on Firefox I got an exception that my a.class was not found… What I’m doing wrong?

luisoft, are you trying to run your applet locally ? Because if you do, it won’t work because of pack200. Then, you should try to put your a.proguard.kz.pack.gz and your html files on a distant server.

You don’t use “.class” when specifying the code. Just use “a”

Also try it out in chrome, in case firefox caches the previous jar.

Tried all 3 suggestions above… neither worked! :’(

I tried to put it in another machine running apache in the same network. Should it work?

I still get class not found error. I tried “a” without “.class” and it didn’t work.

any other suggestion? how can I make sure the “a.class” file is in the packed file?

use unpack200 to exptract the jar

then run it to validate

if it runs, it should be fine.
Else you can still reupload it on Java4k.com if something is not working

luisoft, instead of just this :

pack200 --effort=9 --strip-debug --no-keep-file-order -O --no-gzip a.proguard.pack a.proguard.jar

You should try this :

pack200 --repack a.proguard.jar

pack200 --effort=9 --strip-debug --no-keep-file-order -O --no-gzip a.proguard.pack a.proguard.jar

unpack200 a.proguard.pack a.proguard.test.jar

Then test locally the a.proguard.test.jar file, and if it works, continue on with kzip and your a.proguard.pack file.

Thanks for the compression tool Grobo. I eventually got it to work (there was one bug where the class was embedded in one extra directory but it’s an easy fix) and now my game’s well under 4k. ;D

I also made a python script for ‘brute force’ compression with KZip.
It tries different block sizes with random seed and takes the best one of them.
This usually gives me an additional 10-20 bytes.

EDIT: Ah this has already been mentioned, perfect!

Riven - I just wanted to reiterate how much we’re missing your compression tool. Applet or server-side - either way would be greatly appreciated! Pretty please? :slight_smile:

With sugar on top!!

I’m rather busy, and I doubt it will be useful to release in the last 6 days. Yes, I know, you’ll be like ‘but ofcouse it will be, especially in the last days’ but I’m fairly sure everybody that wanted to write a java4k entry already rolled their own solution, based on the content in this thread.

The applet is 95% done, and has been like that for over a month now. Those last 5% will probably take half a day, and I don’t really expect to be able to work on it in the next few days.