Kronos
|
 |
«
Posted
2013-02-13 18:52:32 » |
|
Hello, I want to contribute to the current 4K contest. My jar is 6.819 Bytes big. I am doing this at the moment with little success: pack200 --repack fourK.jar pack200 fourK.jar.pack.gz fourK.jar The result is 4.420 Bytes. All the shrinking tools seem to be offline  Please help me, thanks guys 
|
|
|
|
davedes
|
 |
«
Reply #1 - Posted
2013-02-13 18:54:45 » |
|
Try JShrink.
|
|
|
|
|
Games published by our own members! Check 'em out!
|
|
forthx
|
 |
«
Reply #3 - Posted
2013-02-13 18:59:39 » |
|
|
|
|
|
Kronos
|
 |
«
Reply #4 - Posted
2013-02-13 19:22:10 » |
|
Thanks for your help  It worked out very well  First I used Jshrinker, than pack200. Now I got a shrink.pack.gz file. How do I test my applet if it still works? 
|
|
|
|
|
Kronos
|
 |
«
Reply #6 - Posted
2013-02-13 21:15:11 » |
|
I tried it your way, but I get errors after the 3rd step with the jarg.jar. But the jshrinker does the job anyway, but I it won't run in the browser, although I added the params to the applet tag. It says no G.class found... Whats wrong there? My steps javac -target 1.7 G.java jar cvfM game.jar G.class jshrink with standard configuration (load and save) pack200 game.pack.gz game.jar
1 2 3 4 5 6 7
| <object type="application/x-java-applet" height="600" width="800"> <param name="code" value="G.class" /> <param name="archive" value="game.pack.gz" /> <param name="java_arguments" value="-Djnlp.packEnabled=true"/> Applet failed to run. No Java plug-in was found. </object> |
|
|
|
|
StephR
|
 |
«
Reply #7 - Posted
2013-02-13 21:42:53 » |
|
I tried it your way, but I get errors after the 3rd step with the jarg.jar. But the jshrinker does the job anyway, but I it won't run in the browser, although I added the params to the applet tag. It says no G.class found... Whats wrong there? Did you try your packed applet on a distant webserver ?
|
|
|
|
teletubo
|
 |
«
Reply #8 - Posted
2013-02-14 00:02:41 » |
|
javac -target 1.7 G.java
reducing the target to 1.5 will save you 300-400 bytes in final jar.
|
|
|
|
Groboclown
|
 |
«
Reply #9 - Posted
2013-02-14 02:15:27 » |
|
I tried it your way, but I get errors after the 3rd step with the jarg.jar.
I'll do some self-promoting here for this. I have collected the different techniques at shrinking my game jars down into a Mercurial project, which can be downloaded here: There's a readme file that will (hopefully) walk you through the setup steps.
|
|
|
|
Games published by our own members! Check 'em out!
|
|
Kronos
|
 |
«
Reply #10 - Posted
2013-02-14 09:06:31 » |
|
@StephR: Yes I tried, and still ClassNotFoundException. I tried letting the Jshrink step out. Still not better. The applet cannot be started trough the webbrowser. @teletubo: Thanks for that  helped a bit
|
|
|
|
BenniBanni
|
 |
«
Reply #11 - Posted
2013-02-14 09:45:35 » |
|
I only used pack200 with the following options: --effort=9 --no-keep-file-order --strip-debug
That worked for me, now the packed "Fuego" has approx 3.700 instead of 4200 bytes...
|
|
|
|
StephR
|
 |
«
Reply #12 - Posted
2013-02-14 12:17:14 » |
|
I tried it your way, but I get errors after the 3rd step with the jarg.jar.
Kronos, can you report accurately all the errors you get on or after the 3rd step described by SimonH ? Even better, report also here everything you type on the command line.Actually, you did it...
|
|
|
|
ClickerMonkey
|
 |
«
Reply #13 - Posted
2013-02-14 12:20:32 » |
|
Use Proguard+Pack200, I get 40k files down to 4k
|
|
|
|
Kronos
|
 |
«
Reply #14 - Posted
2013-02-14 14:44:16 » |
|
I'm getting desperate  I only used eclipse export, than pack200 with mentioned options: --effort=9 --no-keep-file-order --strip-debug and this HTML5 object Tag: 1 2 3 4 5
| <object type="application/x-java-applet" height="600" width="800"> <param name="code" value="G.class" /> <param name="archive" value="jar/game.pack.gz" /> <param name="java_arguments" value="-Djnlp.packEnabled=true"/> </object> |
also with cache_archive. I've seen this several times. Please help me  I want to submit today  P.S.: the applet without pack200'ing it, runs very well in the browser with the object tag.
|
|
|
|
teletubo
|
 |
«
Reply #15 - Posted
2013-02-14 14:53:15 » |
|
you did read what I said that you have to set it up in a real webserver ? You cannot simply create a .html page with this code and double click it. It will not work .
In any case, just submit it and keep trying to set it up on your computer. The approval process takes 1 or 2 days anyway, and by then you'll know if it works or not.
I myself submitted my pack200ed without testing it. If the pure jar works in your machine, pretty much likely it will run pack200 in the java4k site.
|
|
|
|
BenniBanni
|
 |
«
Reply #16 - Posted
2013-02-14 15:10:25 » |
|
Here is the applet-html-snippet from my entry on java4k, maybe that helps? 1 2 3
| <applet code="Fuego.class" archive="fuego.pack.gz" width="800" height="600"> <param name="java_arguments" value="-Djnlp.packEnabled=true" /> </applet> |
|
|
|
|
Kronos
|
 |
«
Reply #17 - Posted
2013-02-14 16:42:48 » |
|
you did read what I said that you have to set it up in a real webserver ? You cannot simply create a .html page with this code and double click it. It will not work .
In any case, just submit it and keep trying to set it up on your computer. The approval process takes 1 or 2 days anyway, and by then you'll know if it works or not.
I myself submitted my pack200ed without testing it. If the pure jar works in your machine, pretty much likely it will run pack200 in the java4k site.
I uploaded it on my website, and nothing happened. I hope the guys from 4K know better to handle that thing  I really hope  Thank you all for your patience 
|
|
|
|
Groboclown
|
 |
«
Reply #18 - Posted
2013-02-14 18:55:18 » |
|
I updated the my Java4k tools to include a trivial HTTPD server that knows how to handle pack200 file requests. If you want to play along without downloading the whole package and getting it running, here's the simple guide: 1. Download the source from here: http://groboutils.hg.sourceforge.net/hgweb/groboutils/java4k/raw-file/28651c630d4f/tools/src/net/sf/groboutils/java4k/httpd/NanoHTTPD.java2. (optional) Remove the package line to make the simple guide easier. 3. Compile NanoHTTPD.java 4. Put a simple html file named "index.html" and your pack200 compressed applet (named *.jar.pack.gz) in an empty directory. For the html page, something simple like this works (replace the attributes in caps with the actual value; notice that the archive name ends in ".jar"): 1 2
| <html><body><applet ARCHIVE="x.jar" CODE="M.class" WIDTH="200" HEIGHT="400"> </applet></body></html> |
5. Run the NanoHTTPD class like: "java -cp . NanoHTTPD -p 8080 -d (directory of html and pack.gz file)" 6. Point your web browser to " http://localhost:8080/"
|
|
|
|
StephR
|
 |
«
Reply #19 - Posted
2013-02-14 18:56:52 » |
|
Kronos, did you try to unpack and test locally the resulting jar in a standard applet code ? 1 2 3
| Input file : game.pack Command line>unpack200 game.pack game.pack.test.jar Output file : game.pack.test.jar |
|
|
|
|
forthx
|
 |
«
Reply #20 - Posted
2013-02-14 21:22:30 » |
|
Groboclown, I try your packing scripts ant at last it work  After reading the readme and installing ant, I have to: - use "resources/global.properties" to create a local.properties (Mandatory for the setting of "default.jdk-dir", i.e. "C:/Program Files/jdk1.7" no /bin !) - change proguard version (I use jdk 1.7 and I solve some error using proguard 4.  - update ant-include.xml (add source="@{jdk-target}" at line 115, in javac-4k macrodef) to avoid javac warning. Hope this help other users. With Kzip, DeflOpt and yguard I reduce my archive size by 200 Bytes (compared to my manual processing using proguard and pack200)!
|
|
|
|
Kronos
|
 |
«
Reply #21 - Posted
2013-02-15 11:35:17 » |
|
Kronos, did you try to unpack and test locally the resulting jar in a standard applet code ? 1 2 3
| Input file : game.pack Command line>unpack200 game.pack game.pack.test.jar Output file : game.pack.test.jar |
That worked, and it is even smaller. However. Does that mean my pack.gz file will work at the 4K website? Thank you very much, I am relieved a bit 
|
|
|
|
StephR
|
 |
«
Reply #22 - Posted
2013-02-15 12:31:27 » |
|
Kronos, did you try this html code on a webserver to test your game.pack.gz file ? Your html page and your game.pack.gz must be into the same directory.
<html> <body> <applet code="G.class" archive="game.pack.gz" width="800" height="600"> <param name="java_arguments" value="-Djnlp.packEnabled=true" /> </applet> </body> </html>
If you did and that it failed, you should consider giving us the URL to your webserver...
|
|
|
|
Riven
|
 |
«
Reply #23 - Posted
2013-02-15 13:00:15 » |
|
To get an pack200 compressed jar working, you need a pack200 aware webserver.
Some idiot at Sun didn't think this through.
|
Hi, appreciate more people! Σ ♥ = ¾ Learn how to award medals... and work your way up the social rankings!
|
|
|
StephR
|
 |
«
Reply #24 - Posted
2013-02-15 19:28:23 » |
|
Thanks for the information, Riven. I had really no idea of this problem. And Kronos, maybe it's time for you to submit your game at the www.java4k.com site.
|
|
|
|
Kronos
|
 |
«
Reply #25 - Posted
2013-02-15 19:39:38 » |
|
Why? Isn't 28.02. the last day to submit? I still have to put some extra flavour in the game 
|
|
|
|
Riven
|
 |
«
Reply #26 - Posted
2013-02-15 19:51:45 » |
|
the Java4K webserver is pack200 aware, and therefore can be used to verify your pack200ed applet actually works.
|
Hi, appreciate more people! Σ ♥ = ¾ Learn how to award medals... and work your way up the social rankings!
|
|
|
pjt33
|
 |
«
Reply #27 - Posted
2013-02-15 21:30:17 » |
|
I updated the my Java4k tools to include a trivial HTTPD server that knows how to handle pack200 file requests.
Didn't you already have mine? If not it must have been someone else who was putting together a collection of resources from across the years.
|
|
|
|
Groboclown
|
 |
«
Reply #28 - Posted
2013-02-15 21:58:26 » |
|
I updated the my Java4k tools to include a trivial HTTPD server that knows how to handle pack200 file requests.
Didn't you already have mine? If not it must have been someone else who was putting together a collection of resources from across the years. Nope, I missed that one. Although, over these years I've only kept a limited amount of the code posted up here. Most of it is either refinements of other code, or one-off snippets, but it would be interesting to see it all together in one place... Hm...
|
|
|
|
|