remove unused class from rt.jar in jre
i tried to remove unused .class files from rt.jar and bundle it to my program but there are 2 problems:
java is a JIT language and some required libs will load after some process like click and ... so if you开发者_开发技巧 delete files with ERROR-SUCCESS method you will fail.
many of classess needed by java runtime for first prepration.
so how i can find out which of class files are not required?
Have look at Bundling a minimal 'bare bones' JVM with your Application to do what you want. The author narrowed down a "Hello World" application to a 5MB JVM. That might not be legal to distribute however, you should probably check into that first.
You might also want to consider just including or linking to the online installer. For Windows it's under 1MB and available here.
Don't bundle rt.jar. You don't need to. It's already distributed with the Java Virtual Machine, and anyone who can run your program already has it.
You cannot just bundle rt.jar, you have to bundle the whole JRE.
On my machine, my rt.jar is about 48meg. I can understand why you wouldn't want to bundle an additional 48meg. However, I did a 7zip compress (default settings in the context menu) and because it's just code, which compresses very well, it compressed down to 10meg.
I would suggest simply compressing and then decompressing on install.
Edit: The entire jre (which I'm assuming you'll need, but that you've already trimmed what files you don't need) compressed to about 21 meg.
精彩评论