http://www.javayou.com (收藏,设为首页)
当你不能再拥有时,你唯一能做的,就是让自己不要忘记 (手机请访问 http://3g.dlog.cn/javayou)

JDK 5/6.0中一个压缩jar文件大小的工具

2007年1月2日(Tuesday) 09点12分 作者: 刘冬 天气: 心情: 一般

Java SE 5 and 6 comes already with a packing tool called "pack200". This tool is able to compress already existing jar files which can be then used for network distribution. I compressed the rt.jar with the following command:

C:\Java\jdk1.6.0\jre\lib>pack200 -J-Xmx256m rt.jar.gz rt.jar

参数-J-X是必须的,否则你可能会收到一个OutOfMemoryError的错误,因为这工具本身也是用Java语言写的,来看看结果吧,神奇的结果:

Origin size: 43.8 MB
Compressed size: 5.81 MB

要解压的话可以使用工具"unpack200"

The tool pack200 is especially interesting for the distribution of WebStart applications to achieve faster download times. There is already one another well known sample - glassfish. In the second installation stage, glassfish unpacks internal libraries using the unpack200 tool...

认真的看看最后这段话便可知这工具有何用途:)

标签: JDK Java 
评论者: Jonney 2007-1-2 10:41 (Tuesday)
哇塞,太神奇了,无敌金牌压缩王!到底是什么原理?
评论者: king 2007-1-4 10:30 (Thursday)
压缩的速度超慢,这命令是不是有问题
评论者: rob 2007-1-4 10:32 (Thursday)
出问题了,压缩后的文件解压缩出来的文件较压缩前的小得多,而且提示损坏了
评论者: king 2007-1-4 10:43 (Thursday)
解压缩时用unpack200解,用其他的当然会出问题
姓名: 
邮箱:  {可选}
网址:  {可选} 此评论只有我和写日记的人查阅
校验码: ... <我看不清楚>
网记为您提供手机和互联网同步的个人主页,带给你不一样的体验