- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
alternative to ProGuard - SJar 0.1
Sat, 2011-05-21, 22:40
Hi,
I tried to write a simple program that has some of the functionality
of ProGuard.
It can take a scala/java program and put it's class files plus
whatever classes are needed from the scala library into a jar.
It also removes everything that isn't needed - unused methods,
debugging information, etc.
It's very simple to use. You just need to have SCALA_HOME and
JAVA_HOME set correctly.
Then you can run it e.g. like this "sjar myprogram.jar -o
myprogram2.jar" and you get a jar called myprogram2.jar
which can then be run by java without needing the scala libraries.
I put a first version of the program on megaupload
http://www.megaupload.com/?d=8RO0WGKX
I was wondering what you guys think about it. Any suggestions?
BTW. I noticed that the best way to get jar files really small is by
using double compression.
i.e. You take your folder with the class files in it and make an
umcompressed zip archive out of it. (set compression level to "store")
Then you take that zip file and put it into a second zip file using
the highest compression level.
That way you get a file that is less then half the size you get when
you compress the folder directly at highest level.
Now if the JVM just had support for jar files that are compressed like
that we could make e.g. applets much smaller.
Sun, 2011-05-22, 02:17
#2
RE: alternative to ProGuard - SJar 0.1
> -----Original Message-----
> From: scala-language@googlegroups.com [mailto:scala-
> language@googlegroups.com] On Behalf Of SpiderPig
>
> BTW. I noticed that the best way to get jar files really small is by using
double
> compression.
> i.e. You take your folder with the class files in it and make an
umcompressed
> zip archive out of it. (set compression level to "store") Then you take
that zip
> file and put it into a second zip file using the highest compression
level.
> That way you get a file that is less then half the size you get when you
> compress the folder directly at highest level.
This works because the algorithm used by zip is applied to each component
file separately and thus needs to restart itself for each file. If you pack
all the files into a single uncompressed archive and then compress that
archive you get better results because the compression algorithm does not
need to restart on the individual files.
The dark side of that approach, however, is that accessing the individual
component files tends to be slow. Typically before one can decompress a
randomly selected file it is necessary to decompress all preceding files. In
other words random access of individual component files becomes extremely
slow.
Peter
Sun, 2011-05-22, 02:57
#3
Re: alternative to ProGuard - SJar 0.1
Hi
> BTW. I noticed that the best way to get jar files really small is by
> using double compression.
> i.e. You take your folder with the class files in it and make an
> umcompressed zip archive out of it. (set compression level to "store")
> Then you take that zip file and put it into a second zip file using
> the highest compression level.
> That way you get a file that is less then half the size you get when
> you compress the folder directly at highest level.
> Now if the JVM just had support for jar files that are compressed like
> that we could make e.g. applets much smaller.
Isn't that exactly what tar.gz does? Depending on which zip you use
there should be an option for that afaik sometimes called "solid archive".
Bye,
Simon
The support for alternate handling of .jar files need not be built into the JVM. You can write a classloader to handle it.
-----Original Message-----
From: scala-language@googlegroups.com [mailto:scala-language@googlegroups.com] On Behalf Of SpiderPig
Sent: Saturday, May 21, 2011 5:40 PM
To: scala-language
Subject: [scala-language] alternative to ProGuard - SJar 0.1
Hi,
I tried to write a simple program that has some of the functionality
of ProGuard.
It can take a scala/java program and put it's class files plus
whatever classes are needed from the scala library into a jar.
It also removes everything that isn't needed - unused methods,
debugging information, etc.
It's very simple to use. You just need to have SCALA_HOME and
JAVA_HOME set correctly.
Then you can run it e.g. like this "sjar myprogram.jar -o
myprogram2.jar" and you get a jar called myprogram2.jar
which can then be run by java without needing the scala libraries.
I put a first version of the program on megaupload
http://www.megaupload.com/?d=8RO0WGKX
I was wondering what you guys think about it. Any suggestions?
BTW. I noticed that the best way to get jar files really small is by
using double compression.
i.e. You take your folder with the class files in it and make an
umcompressed zip archive out of it. (set compression level to "store")
Then you take that zip file and put it into a second zip file using
the highest compression level.
That way you get a file that is less then half the size you get when
you compress the folder directly at highest level.
Now if the JVM just had support for jar files that are compressed like
that we could make e.g. applets much smaller.
________________________________
This e-mail message (including any attachments) is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination, distribution
or copying of this message (including any attachments) is strictly
prohibited.
If you have received this message in error, please contact
the sender by reply e-mail message and destroy all copies of the
original message (including attachments).