The best way to find out is to try and see; for example use java -verbose. to run a minimal program in different languages ββhosted on the JVM.
But the answer is likely to be:
- JVM specification, and
- programming language.
I should also indicate that the answer (s) you get will not be of practical use (... if you do not plan to create an abbreviated JRE. And if so, read the following below.)
Do you know that all classes are strictly necessary, or does the VM also preload classes that are expected to be used in all cases by applications?
The JVM does not preload on this basis. Rather, it loads the closure of the dependencies your code depends on. Depending on which classes your application uses, this may result in loading classes that are not actually used. Sun engineers have done a great job to try to reduce this effect over the years, but undoubtedly this still happens to some extent.
FOLLOW UP
Reading between the lines, it seems that the goal is to create an abbreviated JVM package to support runtime requirements in some other language. If so, consider the following points:
There are licensing requirements for what you can do with Java with respect to creating shortened versions. In particular, Java, JVM, and JRE are trademarks, and Oracle may appear after you if you use them in the context of the abbreviated JRE. (I'm not saying that you cannot do this, but you need to check the legal aspects for yourself.)
There are certain support issues. For example, you need to keep track of any relevant security issues and Java / JVM patches and create new versions of your underlying platform as recommended.
If you intend to somehow apply applications in your new language to invoke Java libraries, then using the shortened JRE can be a serious back pain for some users. Especially if you pack your things so that they use your cut JRE.
There are tools in the JRE / JDK that may be useful to you / your users. Tools like profilers, debuggers, JAR commands, etc. Your JRE will need to include all the classes necessary to run them.
Finally, downloading 100 MB is not a significant issue for VAST MAJORITY users. And if so, you can make some money to support your project by selling installer DVDs.
Focus on what you are really trying to do here ... and leave the installer optimization when you have something like product quality for optimization.
Stephen c
source share