Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Easy shrink method  (Read 3183 times)
0 Members and 1 Guest are viewing this topic.
Offline Kronos

Junior Devvie


Medals: 1



« 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:

Quote
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 Sad

Please help me, thanks guys Smiley
Offline davedes
« Reply #1 - Posted 2013-02-13 18:54:45 »

Try JShrink.

Offline Kronos

Junior Devvie


Medals: 1



« Reply #2 - Posted 2013-02-13 18:55:29 »

I already tried to download it, but the download link is broken

http://www.e-t.com/jshrink.zip
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline forthx

Junior Devvie


Medals: 1
Projects: 1



« Reply #3 - Posted 2013-02-13 18:59:39 »

use evaluation (the link work):

http://www.e-t.com/jshrinkevaljar.zip

Or proguard :
http://proguard.sourceforge.net/

Or both if you need !
Offline Kronos

Junior Devvie


Medals: 1



« Reply #4 - Posted 2013-02-13 19:22:10 »

Thanks for your help Cheesy

It worked out very well Cheesy
First I used Jshrinker, than pack200. Now I got a shrink.pack.gz file. How do I test my applet if it still works?

 Huh
Offline teletubo
« League of Dukes »

JGO Ninja


Medals: 48
Projects: 4
Exp: 8 years



« Reply #5 - Posted 2013-02-13 19:37:33 »

I use the method described here:
http://www.java-gaming.org/topics/indiespot-compression-not-working/25147/msg/217257/view.html#msg217257

Using all those steps on my jar, I reduce the final output from 6.962 bytes to  3.860 bytes.


To test a pack200ed jar you have to setup a webserver and use the packEnabled parameter.

1  
2  
<applet code="A.class" archive="game.pack.gz" width="495" height="450" >
< param name="java_arguments" value="-Djnlp.packEnabled=true" />

Offline Kronos

Junior Devvie


Medals: 1



« 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... Sad

Whats wrong there?

My steps

Quote
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>
Offline StephR

Senior Devvie


Medals: 9



« 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... Sad

Whats wrong there?


Did you try your packed applet on a distant webserver ?
Offline teletubo
« League of Dukes »

JGO Ninja


Medals: 48
Projects: 4
Exp: 8 years



« Reply #8 - Posted 2013-02-14 00:02:41 »

 
Quote
javac -target 1.7 G.java

 
reducing the target to 1.5 will save you 300-400 bytes in final jar.

Offline 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:

1  
hg clone http://groboutils.hg.sourceforge.net:8000/hgroot/groboutils/java4k


There's a readme file that will (hopefully) walk you through the setup steps.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Kronos

Junior Devvie


Medals: 1



« 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 Smiley helped a bit
Offline BenniBanni

Senior Devvie


Medals: 2
Projects: 2



« 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...
Offline StephR

Senior Devvie


Medals: 9



« 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...
Offline ClickerMonkey

JGO Coder


Medals: 20


Game Engineer


« Reply #13 - Posted 2013-02-14 12:20:32 »

Use Proguard+Pack200, I get 40k files down to 4k

Offline Kronos

Junior Devvie


Medals: 1



« Reply #14 - Posted 2013-02-14 14:44:16 »

I'm getting desperate Sad

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 Smiley I want to submit today  Shocked


P.S.: the applet without pack200'ing it, runs very well in the browser with the object tag.
Offline teletubo
« League of Dukes »

JGO Ninja


Medals: 48
Projects: 4
Exp: 8 years



« 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.

Offline BenniBanni

Senior Devvie


Medals: 2
Projects: 2



« 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>
Offline Kronos

Junior Devvie


Medals: 1



« 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 Cheesy I really hope Wink

Thank you all for your patience Wink
Offline 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.java
2. (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/"

Offline StephR

Senior Devvie


Medals: 9



« 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
Offline forthx

Junior Devvie


Medals: 1
Projects: 1



« Reply #20 - Posted 2013-02-14 21:22:30 »

Groboclown, I try your packing scripts ant at last it work Wink

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.Cool
- 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)!
Offline Kronos

Junior Devvie


Medals: 1



« 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  Cool
Offline StephR

Senior Devvie


Medals: 9



« 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...
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 847
Projects: 4
Exp: 16 years


Hand over your head.


« 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
Offline StephR

Senior Devvie


Medals: 9



« 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.
Offline Kronos

Junior Devvie


Medals: 1



« 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 Cheesy
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 847
Projects: 4
Exp: 16 years


Hand over your head.


« 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
Offline 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.
Offline 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...

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Mr.CodeIt (20 views)
2014-12-23 03:34:11

rwatson462 (52 views)
2014-12-15 09:26:44

Mr.CodeIt (45 views)
2014-12-14 19:50:38

BurntPizza (80 views)
2014-12-09 22:41:13

BurntPizza (110 views)
2014-12-08 04:46:31

JscottyBieshaar (78 views)
2014-12-05 12:39:02

SHC (89 views)
2014-12-03 16:27:13

CopyableCougar4 (93 views)
2014-11-29 21:32:03

toopeicgaming1999 (155 views)
2014-11-26 15:22:04

toopeicgaming1999 (148 views)
2014-11-26 15:20:36
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!