JRE8 打包瘦身(180M的JRE瘦身成11M,OMG)

最近接到一个考试软件的试用版,需要让用户下载到本地,解压后直接运行的。对于C#来说这都不是事,可以JAVA就惨了,JRE本身就180多M,让用户下载这么大个包,一定会被吐槽。于是要瘦身。


首先去这里下载一个javase8。之所以需要他,是因为他有个jrecreate的工具(bat和sh都有),可以按照压缩profile来整出不同的JRE瘦身版,包括compact1、2、3三个等级。compact1不到10M,但运行tomcat时出错,compact2才11M多,可正常运行tomcat并加载web应用。


http://www.oracle.com/technetwork/java/embedded/downloads/java-embedded-java-se-download-359230.html#javase8


Java SE 8 is the first Java release to incorporate JRE ‘profiles’, customized subsets of JRE libraries according to the needs of your app.
From the SE Embedded you need to create the JRE based on a selected profile and then copy it across to your device:
./bin/jrecreate.sh --help
./bin/jrecreate.sh--help
to get a list of the options (more noteshere).
To run the above on a Mac, you’ll need to set your JAVA_HOME first, assuming you already have an SE JDK installed. The Java install on Macs is different from other platforms, to handle having multiple versions installed. I have notes in a previous post on how to do thishere.
Create a compact1 profile jre with:
./bin/jrecreate.sh --dest jre8 -p compact1
./bin/jrecreate.sh--destjre8-pcompact1
Zip the created dir with
zip -r jre8.zip jre8/*
zip-rjre8.zipjre8/*
Scp it over to your target device, unzip and you’re ready to go!


附件是compact2的压缩版本


参考地址:
http://my.oschina.net/benhaile/blog/211804

猜你喜欢

转载自lgcjava.iteye.com/blog/2322800
JRE
今日推荐