减少JRE的大小

ase*_*a38 25 java jvm

我们将Java 6 JRE与我们的应用程序安装程序捆绑在一起,以便它可以在任何机器上运行,但这会使应用程序变得更重一些.所以我们计划减少JRE的规模.如果有人做过这类任务,你能否提供指导以推进这项工作?

Ang*_*own 25

查看JRE目录中的README文件."可选文件和目录"部分列出了一些文件,如果您将其与应用程序打包在一起,则可以从Oracle/Sun JRE中删除这些文件.

在创建安装时,我使用Ant构建文件将JRE从系统安装位置复制到包目录.将要排除的文件列表放在单独的文件中,并使用'excludesfile'属性加载此列表:

<copy todir="${deployed_jre_dir}">
  <fileset dir="${system_jre_dir}" excludesfile="jre_excludes.properties" 
</copy>
Run Code Online (Sandbox Code Playgroud)

示例jre_excludes.properties文件:

# per the README from the JRE, these files are for the browser plugin and are not needed otherwise
#bin/javaw.exe
bin/javaws.exe
bin/javacpl.exe
bin/jucheck.exe
bin/jusched.exe
bin/wsdetect.dll
bin/NPJPI*.dll
bin/NPJava*
bin/NPOJI610.dll
bin/RegUtils.dll
bin/axbridge.dll
bin/deploy.dll
bin/jpicom.dll
bin/javacpl.cpl
bin/jpiexp.dll
bin/jpinscp.dll
bin/jpioji.dll
bin/jpishare.dll
lib/deploy.jar
lib/plugin.jar
lib/javaws.jar
lib/javaws/messages*
lib/javaws/miniSplash.jpg
bin/new_plugin**
bin/jureg*
bin/ssv*
bin/jqs*
bin/jp2*
lib/deploy/**/*

# if you do not need any RMI stuff
# wildcard to catch .exe files on Windows
# note rmi.dll is not excluded, which is needed by jconsole; add rmi.dll if you do not need jsonsole
bin/jbroker*
bin/java-rmi*
bin/rmid*
bin/rmiregistry*
bin/tnameserv*
bin/orbd*
bin/servertool*

# do not include QuickTime
# this will be in the jre dir for machines that have QT installed
lib/ext/QTJava.zip
Run Code Online (Sandbox Code Playgroud)

  • 对于好奇,在我的64位Windows JRE6上执行此操作将安装从97.7 MB(19.2 MB 7z压缩)降至89.9 MB(17.9 MB 7z压缩),因此约为-7%. (7认同)
  • 我认为java.exe是可选的,因为你可以使用javaw.exe.javaw可能是首选,因为它不会打开控制台窗口. (4认同)
  • 是否有任何已删除的jre可选文件供我们下载.这可能会节省其他人一次又一次重新发明轮子.. (2认同)