简体   繁体   English

如何为JRE 1.6创建rt.jar?

[英]How was rt.jar created for JRE 1.6?

So here is what I did - 所以这就是我做的 -

I unzipped the contents of rt.jar into a folder called rt. 我将rt.jar的内容解压缩到一个名为rt的文件夹中。 Then, inside rt folder, I executed the following jar command 然后,在rt文件夹中,我执行了以下jar命令

jar cf rt.jar *

This should create a jar file with the same classes as that in the original rt.jar file. 这应该创建一个与原始rt.jar文件中的类相同的jar文件。

However, the file sizes of the two files are significantly different. 但是,这两个文件的文件大小明显不同。

Original rt.jar      -> 43.1 MB
Newly created rt.jar -> 20.6 MB

Note that the size of the unzipped contents for both the jar files is the same. 请注意,两个jar文件的解压缩内容的大小是相同的。 This makes me think that the original rt.jar wasn't created using the jar command. 这让我觉得原来的rt.jar不是用jar命令创建的。 So how was it created? 那是怎么创造的?

It's possible that it was created with the -0 option to the jar command, which specifically doesn't apply ZIP compression but just stores the files. 它可能是使用jar命令的-0选项创建的,它特别不应用ZIP压缩但只存储文件。

Since this archive will be read a lot , and by modern standards it's very small, the reduced runtime overhead would seem to be worth it for the sake of 23MB. 由于这个存档将被大量阅读,并且按现代标准来说它非常小,因此为了23MB,减少运行时开销似乎是值得的。

(In any case, even if this isn't strictly correct, the difference in filesize is going to be down to different levels of compression.) (无论如何,即使这不是严格正确的,文件大小的差异也会降低到不同的压缩级别。)

The original jar is created with 0 compression level to make loading classes less CPU intensive. 原始jar使用0压缩级别创建,以使加载类减少CPU密集度。

> unzip -v rt.jar
Archive:  rt.jar
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
       0  Stored        0   0% 02-03-2012 21:20 00000000  META-INF/
    2343  Stored     2343   0% 02-03-2012 21:20 a653ef50  META-INF/MANIFEST.MF
     754  Stored      754   0% 02-03-2012 21:12 fa8ba6d9  com/oracle/net/Sdp$1.class
     350  Stored      350   0% 02-03-2012 21:12 ca729c09  com/oracle/net/Sdp$SdpSocket.class
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM