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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章